UPDATE: Apparently, using sudo to install node modules is not recommended. Instead, changing folder permissions will resolve this issue.
See the answer here: stack overflow
ORIGINAL MAIL:
I have currently installed node (version v0.12.7) and NPM. I am trying to install mean-cli from NPM.
I follow the installation instructions found here: https://github.com/linnovate/mean#installation
In addition, I took the MEAN Stack development course at Udemy. Here is a lecture: https://www.udemy.com/mean-stack-for-beginners/#/lecture/2697540
So far, I have installed both prerequisite packages, Gulp and Bower:
$ npm install -g gulp // and bower $ npm install -g bower
First, I tried installing using npm install -g mean-cli , but this led to permission errors without using sudo . Then even using sudo will not work.
Secondly, I tried updating and reinstall node and NPM. Still having the same problem.
When I type the command sudo npm install -g mean-cli ,
I get this answer:
> mean-cli@0.10.14 preinstall /usr/local/lib/node_modules/mean-cli > node ./scripts/preinstall shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied node.js:720 var cwd = process.cwd(); ^ Error: EACCES, permission denied at Error (native) at Function.startup.resolveArgv0 (node.js:720:23) at startup (node.js:63:13) at node.js:814:3 npm ERR! Darwin 14.4.0 npm ERR! argv "node" "/usr/local/bin/npm" "install" "-g" "mean-cli" npm ERR! node v0.12.7 npm ERR! npm v2.11.3 npm ERR! code ELIFECYCLE npm ERR! mean-cli@0.10.14 preinstall: `node ./scripts/preinstall` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the mean-cli@0.10.14 preinstall script 'node ./scripts/preinstall'. npm ERR! This is most likely a problem with the mean-cli package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! node ./scripts/preinstall npm ERR! You can get their info via: npm ERR! npm owner ls mean-cli npm ERR! There is likely additional logging output above. npm ERR! Please include the following file with any support request: npm ERR! /Library/WebServer/Documents/NodeJS/mean/npm-debug.log
It seems that the problem lies here: Failed at the mean-cli@0.10.14 preinstall script 'node , but I'm not sure how to debug this further.
Any insight or helpful information is appreciated! Thanks!