I'm getting an error installing webserver "connect" with nodejs npm

After installing Node.js on Windows 7 from an admin account and verifying it runs, I attempted to install a webserver.

C:\nodejs> npm install connect

I get the following npm-debug log:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\nodejs\\\\node.exe',
1 verbose cli   'C:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install',
1 verbose cli   'connect' ]
2 info using npm@1.4.23
3 info using node@v0.10.31
4 verbose node symlink C:\nodejs\\node.exe
5 error Error: ENOENT, stat 'C:\Users\One\AppData\Roaming\npm'
6 error If you need help, you may report this *entire* log,
6 error including the npm and node versions, at:
6 error     <http://github.com/npm/npm/issues>
7 error System Windows_NT 6.1.7601
8 error command "C:\\nodejs\\\\node.exe" "C:\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "connect"
9 error cwd C:\nodejs
10 error node -v v0.10.31
11 error npm -v 1.4.23
12 error path C:\Users\One\AppData\Roaming\npm
13 error code ENOENT
14 error errno 34
15 verbose exit [ 34, true ]

Can anyone help?

You didn't install node properly: you installed it "as admin" so it installed it for the admin account, not for you. Now you're running it as user "One" and it's trying to find your profile's npm dir, which was never made, because "you" didn't install it.

So: grab the .msi installer from nodejs.org again, run it as yourself, and when the install process asks for permission with a UAC popup, then grant the permission with the admin password.

(This is a general thing: don't install things "as admin", install things as yourself, and when UAC requires admin permission, give those. Otherwise you're installing things as the wrong user)

Manually creating a folder named 'npm' in the displayed path fixed the problem.

or or

I ran into the same problem while installing a package via npm and after creating the npm folder manually in C:\Users\UserName\AppData\Roaming\ that particular error was gone but it gave similar multiple errors as it tried to create additional directories in npm folder and failed. Issue was resolved after running the command prompt as administrator.

It worked for me when I did the following.

  1. Open nodejs command prompt as administrator.
  2. Change the directory to Node.js installation directory. For example in my computer the Node.js directory is located at C:\Program Files\nodejs
  3. Run this command: npm install connect