NPM always asks me about the root of the Express project

Since I use Express.js, I can no longer use npm install . I always need to root for it to work ...

Let's say I create a project with

 express --sessions --css css 

When I try to execute npm install after, I have these errors

 npm WARN package.json application-name@0.0.1 No README.md file found! npm ERR! Error: EACCES, open '/Users/Arnaud/.npm/e7d16cae-express-3-1-1.lock' npm ERR! { [Error: EACCES, open '/Users/Arnaud/.npm/e7d16cae-express-3-1-1.lock'] npm ERR! errno: 3, npm ERR! code: 'EACCES', npm ERR! path: '/Users/Arnaud/.npm/e7d16cae-express-3-1-1.lock' } npm ERR! npm ERR! Please try running this command again as root/Administrator. npm ERR! System Darwin 12.3.0 npm ERR! command "node" "/usr/local/bin/npm" "install" npm ERR! cwd /Users/Arnaud/Sites/test npm ERR! node -v v0.10.2 npm ERR! npm -v 1.2.15 npm ERR! path /Users/Arnaud/.npm/e7d16cae-express-3-1-1.lock npm ERR! code EACCES npm ERR! errno 3 npm ERR! stack Error: EACCES, open '/Users/Arnaud/.npm/e7d16cae-express-3-1-1.lock' npm ERR! npm ERR! Additional logging details can be found in: npm ERR! /Users/Arnaud/Sites/test/npm-debug.log npm ERR! not ok code 0 

But if you do sudo npm install , all this is good ... Any idea why?

+6
source share
2 answers

This is probably a permission issue. To return ownership of the /Users/Arnaud/.npm directory, run the following command in the terminal

 chown -R Arnaud /Users/Arnaud/.npm 

If you are on OSX, you can also use Disk Utility to restore permissions on the entire disk, which will probably fix the problem for you as well.

+11
source

If you are using a MAC system or a Unix / Lunix machine, you just need to know what for security, even if your root owner must use the sudo command in the line command in the terminal. Therefore, changing ownership of files and directories is not enough to execute the chown command most of the time.

The reason is that the command you execute will have big changes in the system files, and you need to enter the password of your root administrator, as in Windows, when they ask you to enter the administrator password for system changes, so it will look like this:

* Ms-MacBook-Pro: ~ AMB $ sudo npm install -g express-generator

Password: (ENTER PASSWORD FOR ROOT / ADMINISTRATOR)

 /usr/local/bin/express -> /usr/local/lib/node_modules/express-generator/bin/express-cli.js /usr/local/lib └─┬ express-generator@4.15.0 ├─┬ commander@2.9.0 │ └── graceful-readlink@1.0.1 ├── ejs@2.5.6 ├─┬ mkdirp@0.5.1 │ └── minimist@0.0.8 └── sorted-object@2.0.1 

Ms-MacBook-Pro: ~ AMB $ *

0
source

All Articles