Error installing yeoman - node.js

Installing Yeoman on my OSX machine results in the following error:
paulh16$ npm install -g yo
npm http GET https://registry.npmjs.org/yo
npm http 304 https://registry.npmjs.org/yo
npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/yo'
npm ERR! { [Error: EACCES, mkdir '/usr/local/lib/node_modules/yo']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/local/lib/node_modules/yo',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/local/lib/node_modules/yo',
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 13.0.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "yo"
npm ERR! cwd /Users/paulh16/.rvm/lib
npm ERR! node -v v0.10.22
npm ERR! npm -v 1.3.14
npm ERR! path /usr/local/lib/node_modules/yo
npm ERR! fstream_path /usr/local/lib/node_modules/yo
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/yo'
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/paulh16/.rvm/lib/npm-debug.log
npm ERR! not ok code 0
I believe the problem is that bash is looking for npm within the Ruby Version Manager, which is where I installed node and npm originally. However, I removed both from RVM and installed from the Node website. I also adjusted my .bash_profile:
PS1="\u$ "
export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"
export DYLD_LIBRARY_PATH="/usr/local/mysql/lib:$DYLD_LIBRARY_PATH"
if [ -f ~/.git-completion.bash ]; then
source ~/.git-completion.bash
fi
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM$
I don't understand why the Yeoman installation is failing.

This solved the issue for me. Setting the permission on the npm folder in your home directory was the fix for me.
sudo chown -R `whoami` ~/.npm

The npm command fails because you need to be root to edit files under /usr/.
You should properly configure npm, see this relevant SO answer:
$ echo prefix = ~/.node >> ~/.npmrc

try
sudo chown -R $USER /usr/local
and this kind of problem would be solved forever
it's not encouraged to npm with sudo

For me on Ubuntu only the following worked for me...
Ubuntu
Tested on Ubuntu 14.04.2
This was a base install of Ubuntu 14.04.2 on VirtualBox using ubuntu-trusty-64.
I had just installed node and npm fresh and they were working well.
npm install -y -g yo
echo export PATH="$HOME/npm/bin:$PATH" >> ~/.bashrc
npm config set prefix ~/npm
echo "export NODE_PATH=$NODE_PATH:/home/$USER/npm/lib/node_modules" >> ~/.bashrc && source ~/.bashrc
npm install -y -g yo
yes I had to install yeoman, fix the path issues, then reinstall yeoman.
based on some answers on this stack overflow post

This worked well for me:
sudo npm install -g yo

Related

Error installing modules for node.js

I installed node and everything was ok, but when I've tried to install stylus, for example didn't allow me to do it with :nmp install -g stylus, only with :npm install stylus.
When I try to compile estilos.styl anywhere, then the console gives me
"command not found"
I tried to install stylus in the local folder too, but still same error. Same happens with grunt-cli or any module I try to install with node.
These are the errors:
iMac-de-Eva:~ eva$ npm install stylus -g npm ERR! Error: EACCES, mkdir
'/usr/local/lib/node_modules/stylus' npm ERR! { [Error: EACCES, mkdir
'/usr/local/lib/node_modules/stylus'] npm ERR! errno: 3, npm ERR!
code: 'EACCES', npm ERR! path: '/usr/local/lib/node_modules/stylus',
npm ERR! fstream_type: 'Directory', npm ERR! fstream_path:
'/usr/local/lib/node_modules/stylus', 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:46: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.5.0 npm ERR! command "node"
"/usr/local/bin/npm" "install" "stylus" "-g" npm ERR! cwd /Users/eva
npm ERR! node -v v0.10.33 npm ERR! npm -v 1.4.28 npm ERR! path
/usr/local/lib/node_modules/stylus npm ERR! fstream_path
/usr/local/lib/node_modules/stylus 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/stylus'
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:46: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/eva/npm-debug.log npm ERR! not ok code 0
If you're trying to install globally (which is what the -g switch means) you may have to use sudo: sudo npm install -g [module-name]
EACASSS error means you do not have permissions.
To install globally you need to have elevated permissions, this will help:
sudo npm install -g stylus
It will ask you for the password for security reasons.
Installing locally works without permissions, but as you noticed, command stylus is not found, because it is installed locally and not included into your $PATH.
Try to install using this:
npm install --save [module-name]

EACCESS Error when doing npm install -g bower

When i run a command with -g (global) installation i get EACCESS errors . I read on one of the stack overflow answers that i should use 'sudo chown -R whoami ~/.npm' to run as local/root adminstrator but it didnt help
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/Users/.node/lib/node_modules/bower/.editorconfig'
npm ERR! Please try running this command again as root/Administrator.
npm ERR! System Darwin 13.3.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "bower"
npm ERR! cwd /Users/Documents/tutorials/bookingappdemo
npm ERR! node -v v0.10.29
npm ERR! npm -v 2.0.0-alpha-5
npm ERR! path /Users/.node/lib/node_modules/bower/.editorconfig
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, unlink '/Users/.node/lib/node_modules/bower/.editorconfig'
npm ERR! Additional logging details can be found in:
npm ERR! not ok code 0
If you are an administrator I suggest you run the command as root:
sudo npm install -g bower
I used --unsafe-perm with install e.g
sudo npm install -g learnyounode --unsafe-perm
this helped me install without permissions error, hope this is fixed soon.

Why can't i npm install nodemon or supervisor on OSX 10.8.4?

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

Error while installing express using npm

I already have installed express using
npm install express
but looks like in order too create apps I should install it globally. So I used:
npm install -g express
but received:
npm ERR! Error: EACCES, mkdir '/usr/lib/node_modules/express'
npm ERR! { [Error: EACCES, mkdir '/usr/lib/node_modules/express']
npm ERR! errno: 3,
npm ERR! code: 'EACCES',
npm ERR! path: '/usr/lib/node_modules/express',
npm ERR! fstream_type: 'Directory',
npm ERR! fstream_path: '/usr/lib/node_modules/express',
npm ERR! fstream_class: 'DirWriter',
npm ERR! fstream_stack:
npm ERR! [ '/usr/lib/node_modules/fstream/lib/dir-writer.js:36:23',
npm ERR! '/usr/lib/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 Linux 3.11.2-201.fc19.x86_64
npm ERR! command "node" "/usr/bin/npm" "install" "-g" "express"
npm ERR! cwd /home/parisa
npm ERR! node -v v0.10.19
npm ERR! npm -v 1.3.6
npm ERR! path /usr/lib/node_modules/express
npm ERR! fstream_path /usr/lib/node_modules/express
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/lib/node_modules/express'
npm ERR! fstream_stack /usr/lib/node_modules/fstream/lib/dir-writer.js:36:23
npm ERR! fstream_stack /usr/lib/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! /home/parisa/npm-debug.log
npm ERR! not ok code 0
then after trying sudo:
sudo npm install -g express
I get this:
axconfig: unable to open axports file /etc/ax25/axports (No such file or directory)
why is that???
As the error clearly states, you don't have permissions to create in /usr/lib.
stack Error: EACCES, mkdir '/usr/lib/node_modules/express'
hence install with sudo permissions..
sudo npm install -g express
Are you using fedora?
At least in fedora the "node" package is not node.js, It is an amateur radio utility,
axconfig is a file of that software.
npm is not finding nodejs, it is trying to use the wrong software.
Install nodejs package
sudo yum install nodejs
and remove node package
sudo yum remove node
Now npm must work properly for the super user.
edit: Also in debian repositories, the package 'node' is not nodejs
If you are on Arch Linux, check out the npm2arch package in the AUR. It will let you install npm packages using pacman.
Example:
npm2archinstall express

Installing Titanium ACS

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.

Resources