I currently have node.js version 0.8.8, and npm 1.1.59 installed.
Whenever I run:
$ npm install -g express
I get this in return:<
In my case, instead of the ~/.npm directory being owned by root, it was ~/tmp, which I didn't think to check until one of the error messages finally led me to find. Procedure for fixing is pretty easy, since it's a tmp directory, we can just blow it away and start again with one owned by you.
sudo rmdir ~/tmp
mkdir ~/tmp
The solution is:
1 - chown to your user the .npm folder :
sudo chown -R Webmaste /Users/webmaste/.npm/
2 - At your test folder or your folder:
sudo npm install -g express@2.5.8
3 - Invoke express from your actual location:
/usr/local/share/npm/bin/express
4 -
sudo cd . && npm install
5 - finally:
node app
the final message in the console should look like this:
Express server listening on port 3000 in development mode
run npm cache clean
and try to install it again
I had the same problem, and npm cache clear
did not fix it. This problem is caused because the .npm
directory in your home directory was created with root privileges. Most likely the first npm command you ran was sudo npm -g
and now you are trying to npm install
in a local directory.
To solve:
sudo chown -R yourusername ~/.npm
rmdir ~/tmp
npm install
from package.json should work after this.
Run powershell as administrator, then type:
Set-ExecutionPolicy RemoteSigned
then try install again.
As a side note, if you other solutions haven't helped, I have had the same issue and realised what was wrong -- which maybe of interest here.
I had nodemon running on another project -- when I installed locally express. Check you're not running express on another project and trying to install express on a new project. Just a heads up and hope it helps. By the way, just copied the dependency from the package file, and pasted into my new project and ran npm install and checked, express got installed.