Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Npm start issues in AngularJS phonecat application

I downloaded AngularJS phonecat application,and installed bower,http-server,karma,protractor globally. But when I move to directory with code and try 'npm start' ,it runs 'npm install' and shows the following error:

[email protected] prestart /Users/twer/angular-phonecat

npm install

npm WARN locking Error: EACCES, open '/Users/twer/.npm/_locks/bower-d21e2b2886728075.lock' npm WARN locking at Error (native) npm WARN locking /Users/twer/.npm/_locks/bower-d21e2b2886728075.lock failed { [Error: EACCES, open '/Users/twer/.npm/_locks/bower-d21e2b2886728075.lock'] npm WARN locking errno: -13, npm WARN locking code: 'EACCES', npm WARN locking path: '/Users/twer/.npm/_locks/bower-d21e2b2886728075.lock' } npm ERR! Darwin 13.4.0 npm ERR! argv "node" "/usr/local/bin/npm" "install" npm ERR! node v0.12.2 npm ERR! npm v2.7.4

npm ERR! Attempt to unlock /Users/twer/angular-phonecat/node_modules/bower, which hasn't been locked npm WARN locking Error: EACCES, open '/Users/twer/.npm/_locks/http-server-0dbc63e1ce281434.lock' npm WARN locking at Error (native) npm WARN locking /Users/twer/.npm/_locks/http-server-0dbc63e1ce281434.lock failed { [Error: EACCES, open '/Users/twer/.npm/_locks/http-server-0dbc63e1ce281434.lock'] npm WARN locking errno: -13, npm WARN locking code: 'EACCES', npm WARN locking path: '/Users/twer/.npm/_locks/http-server-0dbc63e1ce281434.lock' } npm ERR! Darwin 13.4.0 npm ERR! argv "node" "/usr/local/bin/npm" "install" npm ERR! node v0.12.2 npm ERR! npm v2.7.4

npm ERR! Attempt to unlock /Users/twer/angular-phonecat/node_modules/http-server, which hasn't been locked npm WARN locking Error: EACCES, open '/Users/twer/.npm/_locks/shelljs-e4f96e79494ea210.lock' npm WARN locking at Error (native) npm WARN locking /Users/twer/.npm/_locks/shelljs-e4f96e79494ea210.lock failed { [Error: EACCES, open '/Users/twer/.npm/_locks/shelljs-e4f96e79494ea210.lock'] npm WARN locking errno: -13, npm WARN locking code: 'EACCES', npm WARN locking path: '/Users/twer/.npm/_locks/shelljs-e4f96e79494ea210.lock' } npm ERR! Darwin 13.4.0 npm ERR! argv "node" "/usr/local/bin/npm" "install" npm ERR! node v0.12.2 npm ERR! npm v2.7.4

npm ERR! Attempt to unlock /Users/twer/angular-phonecat/node_modules/shelljs, which hasn't been locked npm WARN locking Error: EACCES, open '/Users/twer/.npm/_locks/karma-e8390a258c010e78.lock' npm WARN locking at Error (native) npm WARN locking /Users/twer/.npm/_locks/karma-e8390a258c010e78.lock failed { [Error: EACCES, open '/Users/twer/.npm/_locks/karma-e8390a258c010e78.lock'] npm WARN locking errno: -13, npm WARN locking code: 'EACCES', npm WARN locking path: '/Users/twer/.npm/_locks/karma-e8390a258c010e78.lock' } npm ERR! Darwin 13.4.0 npm ERR! argv "node" "/usr/local/bin/npm" "install" npm ERR! node v0.12.2 npm ERR! npm v2.7.4

npm ERR! Attempt to unlock /Users/twer/angular-phonecat/node_modules/karma, which hasn't been locked npm WARN locking Error: EACCES, open '/Users/twer/.npm/_locks/protractor-a03b9e77140a9911.lock' npm WARN locking at Error (native) npm WARN locking /Users/twer/.npm/_locks/protractor-a03b9e77140a9911.lock failed { [Error: EACCES, open '/Users/twer/.npm/_locks/protractor-a03b9e77140a9911.lock'] npm WARN locking errno: -13, npm WARN locking code: 'EACCES', npm WARN locking path: '/Users/twer/.npm/_locks/protractor-a03b9e77140a9911.lock' } npm ERR! Darwin 13.4.0 npm ERR! argv "node" "/usr/local/bin/npm" "install" npm ERR! node v0.12.2 npm ERR! npm v2.7.4

npm ERR! Attempt to unlock /Users/twer/angular-phonecat/node_modules/protractor, which hasn't been locked npm WARN locking Error: EACCES, open '/Users/twer/.npm/_locks/karma-chrome-launcher-4c47483197e76b06.lock' npm WARN locking at Error (native) npm WARN locking /Users/twer/.npm/_locks/karma-chrome-launcher-4c47483197e76b06.lock failed { [Error: EACCES, open '/Users/twer/.npm/_locks/karma-chrome-launcher-4c47483197e76b06.lock'] npm WARN locking errno: -13, npm WARN locking code: 'EACCES', npm WARN locking path: '/Users/twer/.npm/_locks/karma-chrome-launcher-4c47483197e76b06.lock' } npm ERR! Darwin 13.4.0 npm ERR! argv "node" "/usr/local/bin/npm" "install" npm ERR! node v0.12.2 npm ERR! npm v2.7.4

npm ERR! Attempt to unlock /Users/twer/angular-phonecat/node_modules/karma-chrome-launcher, which hasn't been locked npm WARN locking Error: EACCES, open '/Users/twer/.npm/_locks/karma-jasmine-435fcdaa8b86b427.lock' npm WARN locking at Error (native) npm WARN locking /Users/twer/.npm/_locks/karma-jasmine-435fcdaa8b86b427.lock failed { [Error: EACCES, open '/Users/twer/.npm/_locks/karma-jasmine-435fcdaa8b86b427.lock'] npm WARN locking errno: -13, npm WARN locking code: 'EACCES', npm WARN locking path: '/Users/twer/.npm/_locks/karma-jasmine-435fcdaa8b86b427.lock' } npm ERR! Darwin 13.4.0 npm ERR! argv "node" "/usr/local/bin/npm" "install" npm ERR! node v0.12.2 npm ERR! npm v2.7.4

npm ERR! Attempt to unlock /Users/twer/angular-phonecat/node_modules/karma-jasmine, which hasn't been locked npm WARN locking Error: EACCES, open '/Users/twer/.npm/_locks/tmp-44bc7858c2a6d09a.lock' npm WARN locking
at Error (native) npm WARN locking /Users/twer/.npm/_locks/tmp-44bc7858c2a6d09a.lock failed { [Error: EACCES, open '/Users/twer/.npm/_locks/tmp-44bc7858c2a6d09a.lock'] npm WARN locking errno: -13, npm WARN locking code: 'EACCES', npm WARN locking path: '/Users/twer/.npm/_locks/tmp-44bc7858c2a6d09a.lock' } npm ERR! Darwin 13.4.0 npm ERR! argv "node" "/usr/local/bin/npm" "install" npm ERR! node v0.12.2 npm ERR! npm v2.7.4

npm ERR! Attempt to unlock /Users/twer/angular-phonecat/node_modules/tmp, which hasn't been locked

npm ERR! Darwin 13.4.0 npm ERR! argv "node" "/usr/local/bin/npm" "start" npm ERR! node v0.12.2 npm ERR! npm v2.7.4 npm ERR! code ELIFECYCLE npm ERR! [email protected] prestart: npm install npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] prestart script 'npm install'. npm ERR! This is most likely a problem with the angular-phonecat package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! npm install npm ERR! You can get their info via: npm ERR! npm owner ls angular-phonecat npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request: npm ERR! /Users/twer/angular-phonecat/npm-debug.log

How can I fix it? Thanks in advance.

like image 491
kristin Avatar asked Mar 17 '23 11:03

kristin


1 Answers

These errors mean that npm cannot access the directory /Users/twer and its subdirectories because of the wrong permissions.

You want to run npm with your own user permission, so set them with by changing the ownership with

chown -R $USER <directory>

or

chown -R `whoami` <directory>

-- both commands do the same, where <directory> is:

  • your home directory (/Users/twer) for local installations;
  • your machine directory for non-system packages, /usr/local or whatever top directory is npm trying to use, that you see in your error messages, you would likely need to prefix your command with sudo in that case.

The option -R here is for recursive as it sets correct ownership also to all subdirectories, which is exactly what you want.

You want to avoid running npm with sudo ever, as recommended by the npm creator Isaac Schlueter:

I strongly encourage you not to do package management with sudo! Packages can run arbitrary scripts, which makes sudoing a package manager command as safe as a chainsaw haircut. Sure, it’s fast and definitely going to cut through any obstacles, but you might actually want that obstacle to stay there.

like image 169
Dmitri Zaitsev Avatar answered Apr 01 '23 01:04

Dmitri Zaitsev