We're trying to install Titaniums ACS via command line using
sudo npm -g install acs
however it keeps failing and we get the below error
npm http GET https://registry.npmjs.org/bindings
> bson#0.0.4 install /usr/local/lib/node_modules/acs/node_modules/connect-mongo/node_modules/mongodb/node_modules/bson
> node install.js
sh: node: command not found
npm ERR! Error: ENOENT, lstat '/usr/local/lib/node_modules/acs/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/WebSocketMain.swf'
npm ERR! If you need help, you may report this log at:
npm ERR! <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR! <npm-#googlegroups.com>
npm ERR! System Darwin 12.3.0
npm ERR! command "node" "/usr/local/bin/npm" "-g" "install" "acs" "--color" "false"
npm ERR! cwd /Users/titanium
npm ERR! node -v v0.8.22
npm ERR! npm -v 1.2.14
npm ERR! path /usr/local/lib/node_modules/acs/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/WebSocketMain.swf
npm ERR! fstream_path /usr/local/lib/node_modules/acs/node_modules/socket.io/node_modules/socket.io-client/lib/vendor/web-socket-js/WebSocketMain.swf
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/fstream/lib/writer.js:284:26
npm ERR! fstream_stack Object.oncomplete (fs.js:297:15)
npm ERR! bson#0.0.4 install: `node install.js`
npm ERR! `sh "-c" "node install.js"` failed with 127
npm ERR!
npm ERR! Failed at the bson#0.0.4 install script.
npm ERR! This is most likely a problem with the bson package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node install.js
npm ERR! You can get their info via:
npm ERR! npm owner ls bson
npm ERR! There is likely additional logging output above.
npm ERR! System Darwin 12.3.0
npm ERR! command "node" "/usr/local/bin/npm" "-g" "install" "acs" "--color" "false"
npm ERR! cwd /Users/titanium
npm ERR! node -v v0.8.22
npm ERR! npm -v 1.2.14
npm ERR! code ELIFECYCLE
npm http 304 https://registry.npmjs.org/qs/0.5.1
npm http 304 https://registry.npmjs.org/pause/0.0.1
npm http 304 https://registry.npmjs.org/send/0.0.4
npm http 304 https://registry.npmjs.org/bytes/0.1.0
npm http 304 https://registry.npmjs.org/bindings
> hiredis#0.1.15 install /usr/local/lib/node_modules/acs/node_modules/socket.io/node_modules/redis/node_modules/hiredis
> node-gyp rebuild
/usr/local/lib/node_modules/npm/bin/node-gyp-bin/node-gyp: line 2: node: command not found
npm WARN optional dep failed, continuing hiredis#0.1.15
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/titanium/npm-debug.log
npm ERR! not ok code 0
iMac:~ titanium$ node-gyp
-bash: node-gyp: command not found
iMac:~ titanium$ hiredis
-bash: hiredis: command not found
iMac:~ titanium$ apt-get install homebrew
-bash: apt-get: command not found
iMac:~ titanium$ node
> echo 1
... exit
... no
...
>
(^C again to quit)
>
iMac:~ titanium$ node install.js
module.js:340
throw err;
^
Error: Cannot find module '/Users/titanium/install.js'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.runMain (module.js:492:10)
at process.startup.processNextTick.process._tickCallback (node.js:245:9)
However we can type node into the terminal and it runs it fine, and loads of node functionality works perfectly.
If anybody has any insights to this issue it would be very helpful.
Thank you
Did you try clearing the npm cache?
npm cache clean
Looks like node is not in PATH for sudo user.
Either set up node for sudo like given here or run it with sudo -E option.
Don't use npm with root privileges, that is unsafe.
I would suggest you to give ownership to /usr/local to your user, to do so you could do
sudo chown -R $USER /usr/local
as adviced here by npm's author: http://howtonode.org/introduction-to-npm
I tried installing it without sudo and worked ok.
Before installing the CLI, you should decide where you want the Node Package Manager (npm) to install packages. By default npm installs into /usr/local on OS X and Linux, which requires that you run npm as root. This is not recommended. You can avoid having to run npm by doing one of the following:
Make the /usr/local directory writable by all:
sudo chmod 777 /usr/local
Set npm to install to your home directory, or another directory of your choosing by setting the npm prefix. For example, you can add the following to your .bash_profile or other initialization file:
export NPM_CONFIG_PREFIX=$HOME
Alternately, you can create a .npmrc file in your home directory with the following contents:
prefix=/path/to/home
Where /path/to/home is the path to your home directory. Setting the npm prefix to your home directory causes the npm packages to be installed to $HOME/lib/node_modules and launch scripts are installed in $HOME/bin. $HOME/bin must be in your PATH.
If you change your prefix after installing npm packages, you will have to reinstall packages. If you change the permissions on /usr/local after installing packages as root, you may need to change the ownership of the npm cache folder, as described in Troubleshooting npm Problems.
Troubleshooting npm Problems
If you experience an issue installing any of the npm packages, try the following:
Check permissions. If you originally ran npm using sudo, you may need to change the ownership of the npm cache folder.
sudo chown -R <username> ~/.npmrc
On Windows, the npm cache defaults to npm-cache in the user's home directory.
Clear the npm package cache:
npm cache clean
Remove your .npmrc file.
Related
UPDATE:
Apparently, it is bad practice to use sudo to install node modules. Instead, changing folder permissions will solve this issue.
See the answer here: https://stackoverflow.com/a/31546496/2859315
ORIGINAL POST:
Currently, I have installed Node (version v0.12.7) and NPM. I am trying to install the mean-cli package from NPM.
I am following the installation instructions found here: https://github.com/linnovate/mean#installation
Also, I was taking a MEAN Stack development course on Udemy. Here is the 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
Firstly, I tried installing by using npm install -g mean-cli but that threw permission errors without using sudo. Then, even using sudo would not work.
Secondly, I tried updating and reinstalling node and NPM. Still have the same issue.
When I type the command sudo npm install -g mean-cli,
I get this response:
> 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 like the problem lies here: Failed at the mean-cli#0.10.14 preinstall script 'node, but I am not sure about how to debug this further.
Any insight or helpful information is appreciated! Thanks!
Apparently, it is bad practice to use sudo to install node modules. Instead, changing folder permissions will solve this issue.
See the answer here: https://stackoverflow.com/a/31546496/2859315
To reclaim ownership of the /usr/local use the command below
Sudo chown –r $USER /usr/local
I am trying to install yo and a few other packages in nodejs, however I keep getting errors. I am new to node so I am a little lost.
I am running Mac OS X 10.10.3. The command I am using is
sudo npm install --global yo
Doing this gives me the following errors.
> spawn-sync#1.0.13 postinstall /usr/local/lib/node_modules/yo/node_modules/cross-spawn/node_modules/spawn-sync
> node postinstall
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.3.0
npm ERR! argv "node" "/usr/local/bin/npm" "install" "--global" "yo"
npm ERR! node v0.12.7
npm ERR! npm v2.11.3
npm ERR! code ELIFECYCLE
npm ERR! spawn-sync#1.0.13 postinstall: `node postinstall`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the spawn-sync#1.0.13 postinstall script 'node postinstall'.
npm ERR! This is most likely a problem with the spawn-sync package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node postinstall
npm ERR! You can get their info via:
npm ERR! npm owner ls spawn-sync
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /Users/XXXXXXX/npm-debug.log
In general, you should not be using sudo to install node modules.
Instead, use sudo to fix your folder permissions to allow you to do global npm installs.
Take ownership of the .npm directory with
sudo chown -R $(whoami) ~/.npm
And write permission for the node_modules directory with
sudo chown -R $USER /usr/local/lib/node_modules
Then try to run your npm install command again without sudo.
From your Reddit post, I know that
sudo npm cache clean fixed the issue for you.
Figured someone should answer here so anyone else looking to solve this can find it.
Running the following commands should solve the problem.
sudo npm cache clean
sudo npm install -g yo
I installed some nodejs packages globally via
sudo npm install gulp -g
Now I (or another developer on the same machine) wants to use it in a project with
me#host:/my/project$ npm link gulp
It fails with
unbuild gulp#3.8.11
npm ERR! Error: EPERM, chmod '/my/projectnode_modules/gulp/bin/gulp.js'
npm ERR! { [Error: EPERM, chmod '/my/projectnode_modules/gulp/bin/gulp.js']
npm ERR! errno: 50,
npm ERR! code: 'EPERM',
npm ERR! path: '/my/projectnode_modules/gulp/bin/gulp.js' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Linux 3.2.0-4-amd64
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "link" "gulp"
npm ERR! cwd /raid5/workspaces/jgr/aktivglueck-laravel
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.21
npm ERR! path /my/projectnode_modules/gulp/bin/gulp.js
npm ERR! code EPERM
npm ERR! errno 50
npm ERR! stack Error: EPERM, chmod '/my/projectnode_modules/gulp/bin/gulp.js'
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /my/projectnpm-debug.log
npm ERR! not ok code 0
With
sudo npm link gulp
everything works fine.
What I want to know is: Why does npm link need admin permissions? In my understanding I am creating a link inside my project folder where I have full permissions - so what does it do on the global system?
I believe npm link creates a symlink to the current directory in wherever your globally installed node packages are. See here.
If you don't have write rights to that path (you can check with npm config get prefix) you'll get the error you see there.
To avoid having to sudo global installs/links, you could change the ownership/rights of that directory.
i am trying to install gulp via npm on DigitalOcean droplet with following command (with and without sudo):
npm install -g gulp
and im getting errors i cant figure out:
> v8flags#1.0.5 install /root/local/lib/node_modules/gulp/node_modules/v8flags
> node fetch.js
sh: 1: node: Permission denied
npm ERR! Linux 3.13.0-24-generic
npm ERR! argv "node" "/root/local/bin/npm" "install" "-g" "gulp"
npm ERR! node v0.10.33
npm ERR! npm v2.1.11
npm ERR! code ELIFECYCLE
npm ERR! v8flags#1.0.5 install: `node fetch.js`
npm ERR! Exit status 127
npm ERR!
npm ERR! Failed at the v8flags#1.0.5 install script 'node fetch.js'.
npm ERR! This is most likely a problem with the v8flags package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node fetch.js
npm ERR! You can get their info via:
npm ERR! npm owner ls v8flags
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /root/local/bin/npm-debug.log
The node install is made according to this guide.
I had the same issue, installing an earlier version of gulp worked for me:
sudo npm install -g gulp#3.8.8
Found this here: http://forum.ionicframework.com/t/osx-error-v8flags-after-npm-update-ionic/13905/5
Also tried a bunch of other solutions involving solutions as mentioned here:
NPM cannot install dependencies - Attempt to unlock something which hasn't been locked
None of that worked for me.
The error I was getting was this:
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
/
node.js:815
var cwd = process.cwd();
^
Error: EACCES, permission denied
at Function.startup.resolveArgv0 (node.js:815:23)
at startup (node.js:58:13)
at node.js:906:3
I'm just trying to install nodemon or supervisor using terminal, and I keep getting this error which I don't understand. I tried running as the administrator with sudo npm install supervisor -g which seemed to work, but than didn't when i deleted/added some js code. Any ideas?
Squirrels-MacBook-Air:lesson7_examples Squirrel$ npm install nodemon -g
npm http GET https://registry.npmjs.org/nodemon
npm http 304 https://registry.npmjs.org/nodemon
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/nodemon'
npm ERR! { [Error: EACCES, mkdir '/usr/local/lib/node_modules/nodemon']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/local/lib/node_modules/nodemon',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/local/lib/node_modules/nodemon',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack:
npm ERR! [ '/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23',
npm ERR! '/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53',
npm ERR! 'Object.oncomplete (fs.js:107:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Darwin 12.4.1
npm ERR! command "node" "/usr/local/bin/npm" "install" "nodemon" "-g"
npm ERR! cwd /Users/Squirrel/Documents/Code/Memry/Memry_Mongoose
npm ERR! node -v v0.10.21
npm ERR! npm -v 1.3.11
npm ERR! path /usr/local/lib/node_modules/nodemon
npm ERR! fstream_path /usr/local/lib/node_modules/nodemon
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/usr/local/lib/node_modules/nodemon'
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23
npm ERR! fstream_stack /usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /Users/Squirrel/Documents/Code/Memry/Memry_Mongoose/npm-debug.log
npm ERR! not ok code 0
Squirrels-MacBook-Air:lesson7_examples Squirrel$
P.S. I'm running this on a pre-existing template and my dependencies are
"dependencies": {
"mongoose": "~3.6.15",
"express": "~3.3.4",
"jade": "~0.34.1",
"email-validator": "~0.1.2"
}
When I tried sudo this is what happened:
sudo npm install supervisor -g --save
Password:
npm http GET https://registry.npmjs.org/supervisor
npm http 304 https://registry.npmjs.org/supervisor
/usr/local/bin/node-supervisor -> /usr/local/lib/node_modules/supervisor/lib/cli-wrapper.js
/usr/local/bin/supervisor -> /usr/local/lib/node_modules/supervisor/lib/cli-wrapper.js
supervisor#0.5.6 /usr/local/lib/node_modules/supervisor
Which seemed to work. But than in the application code I began to add and delete javascript and click save, yet the effects wouldn't take place unless I restarted the server within terminal.
Late to the party, but it is important to note that you should avoid using sudo when npm installing. It is a huge security risk to sudo npm install as you are giving arbitrary scripts root access to your machine.
Instead you should make yourself the owner of the directories in which the NPM
sudo chown -R $USER /usr/local
and then
sudo chown -R $USER ~/.npm
Now you should be able to run the commands without sudo:
npm install supervisor -g --save
You're encountering an EACCES error, which means you don't have the rights to create a directory in /usr/local/lib/node_modules/nodemon as a standard user in Mac OS X.
There are two solutions:
Run the same command as a superuser, using sudo. The package will be installed in /usr/local/lib/node_modules.
Change npm's settings to install all of your global packages into one of your private folders, that your user has ownership of. See this relevant answer that explains step-by-step the process.
I know I'm late to the question, but you should check out nvm (node's answer to rbenv or virtualenv).
Install:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh | bash
Then add . ~/.nvm/nvm.sh to your ~/.bashrc, ~/.profile, or ~/.zshrc
Usage:
If you wanted to use version 0.10, run nvm install 0.12.7 (or nvm install stable), then nvm use 0.12.7.
Install your libs, EACCESS error-free, and go to town. npm install -g supervisor works just fine!
To load a specific version default in new tabs, use the command nvm alias default 0.12.7