Install express.js on Win8 failed


I had downloaded the latest node.js Win installer. And found node -v works! Now I am trying to install express.

Two methods I've tried:

  1. npm install express -g
  2. download the package.json from website and saved,then typed npm install-g

But all two methods did not work. Can any one give me an hint? (I had executed cmd as administrator,but it still did not work.)

C:\microblog>node -v

C:\microblog>npm install -g
npm http GET
npm http 304
npm http GET
npm ERR! not a package C:\Users\wilsonliu\AppData\Roaming\npm-cache\pause\0.0.1\
npm ERR! Error: EPERM, lstat 'C:\Users\wilsonliu\AppData\Roaming\npm\node_module

Debug txt:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files (x86)\\nodejs\\\\node.exe',
1 verbose cli   'C:\\Program Files (x86)\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'install',
1 verbose cli   'express',
1 verbose cli   '-g' ]
2 info using npm@1.3.14
3 info using node@v0.10.22
4 verbose node symlink C:\Program Files (x86)\nodejs\\node.exe
5 verbose cache add [ 'express', null ]
6 verbose cache add name=undefined spec="express" args=["express",null]
7 verbose parsed url { protocol: null,
7 verbose parsed url   slashes: null,
7 verbose parsed url   auth: null,
7 verbose parsed url   host: null,
7 verbose parsed url   port: null,
7 verbose parsed url   hostname: null,
7 verbose parsed url   hash: null,
7 verbose parsed url   search: null,
7 verbose parsed url   query: null,
7 verbose parsed url   pathname: 'express',
7 verbose parsed url   path: 'express',
7 verbose parsed url   href: 'express' }
8 silly lockFile f3c62de4-express express
9 verbose lock express C:\Users\wilsonliu\AppData\Roaming\npm-cache\f3c62de4-       express.lock
10 silly lockFile f3c62de4-express express
11 silly lockFile f3c62de4-express express
12 verbose addNamed [ 'express', '' ]
13 verbose addNamed [ null, '*' ]
Problem courtesy of: user2837851


Can you delete everything from C:\Users\wilsonliu\AppData\Roaming\npm-cache and try?

If you had run npm with or without sudo earlier, the lockfiles create each time may cause such errors.

Besides it's better to avoid using sudo when installing node packages.

You can specify location under user's home folder while installing node. Even if you have installed node/npm as administrator, you should consider chown the node install dir (mostly /usr/local/node) to your local user: sudo chown <user> /usr/local and sudo chown -R <user> /usr/local/*.

Solution courtesy of: vmx


There is currently no discussion for this recipe.

This recipe can be found in it's original form on Stack Over Flow.