Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NPM no longer working

so I wasn't paying attention and ran this command-

npm install npm install jasmine-node -g 

which caused this -

    npm http GET https://registry.npmjs.org/install npm http GET https://registry.npmjs.org/jasmine-node npm http GET https://registry.npmjs.org/npm npm http 200 https://registry.npmjs.org/install npm http GET https://registry.npmjs.org/install/-/install-0.1.7.tgz npm http 200 https://registry.npmjs.org/install/-/install-0.1.7.tgz npm http 200 https://registry.npmjs.org/jasmine-node npm http GET https://registry.npmjs.org/jasmine-node/-/jasmine-node-1.4.0.tgz npm http 200 https://registry.npmjs.org/jasmine-node/-/jasmine-node-1.4.0.tgz npm http 200 https://registry.npmjs.org/npm npm http GET https://registry.npmjs.org/npm/-/npm-1.2.15.tgz npm http 200 https://registry.npmjs.org/npm/-/npm-1.2.15.tgz npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/install' npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules/install'] npm ERR!   errno: 3, npm ERR!   code: 'EACCES', npm ERR!   path: '/usr/local/lib/node_modules/install', npm ERR!   fstream_type: 'Directory', npm ERR!   fstream_path: '/usr/local/lib/node_modules/install', npm ERR!   fstream_class: 'DirWriter', npm ERR!   fstream_stack:  npm ERR!    [ 'DirWriter._create (/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:297:15)' ] } npm ERR!  npm ERR! Please try running this command again as root/Administrator.  npm ERR! System Darwin 12.0.0 npm ERR! command "node" "/usr/local/bin/npm" "install" "npm" "install" "jasmine-node" "-g" npm ERR! cwd /Users/psanker/Google Drive/Coding/Javascript/WhatsGoingOn npm ERR! node -v v0.8.17 npm ERR! npm -v 1.2.0 npm ERR! path /usr/local/lib/node_modules/install npm ERR! fstream_path /usr/local/lib/node_modules/install 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/install' npm ERR! fstream_stack DirWriter._create (/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:297:15) npm ERR! Error: EACCES, mkdir '/usr/local/lib/node_modules/jasmine-node' npm ERR!  { [Error: EACCES, mkdir '/usr/local/lib/node_modules/jasmine-node'] npm ERR!   errno: 3, npm ERR!   code: 'EACCES', npm ERR!   path: '/usr/local/lib/node_modules/jasmine-node', npm ERR!   fstream_type: 'Directory', npm ERR!   fstream_path: '/usr/local/lib/node_modules/jasmine-node', npm ERR!   fstream_class: 'DirWriter', npm ERR!   fstream_stack:  npm ERR!    [ 'DirWriter._create (/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:297:15)' ] } npm ERR!  npm ERR! Please try running this command again as root/Administrator.  npm ERR! System Darwin 12.0.0 npm ERR! command "node" "/usr/local/bin/npm" "install" "npm" "install" "jasmine-node" "-g" npm ERR! cwd /Users/psanker/Google Drive/Coding/Javascript/WhatsGoingOn npm ERR! node -v v0.8.17 npm ERR! npm -v 1.2.0 npm ERR! path /usr/local/lib/node_modules/jasmine-node npm ERR! fstream_path /usr/local/lib/node_modules/jasmine-node 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/jasmine-node' npm ERR! fstream_stack DirWriter._create (/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:297:15) npm ERR! error rolling back Error: EACCES, unlink '/usr/local/lib/node_modules/npm' npm ERR! error rolling back  [email protected] { [Error: EACCES, unlink '/usr/local/lib/node_modules/npm'] npm ERR! error rolling back   errno: 3, npm ERR! error rolling back   code: 'EACCES', npm ERR! error rolling back   path: '/usr/local/lib/node_modules/npm' } npm ERR! Error: EACCES, unlink '/usr/local/lib/node_modules/npm' npm ERR!  { [Error: EACCES, unlink '/usr/local/lib/node_modules/npm'] npm ERR!   errno: 3, npm ERR!   code: 'EACCES', npm ERR!   path: '/usr/local/lib/node_modules/npm' } npm ERR!  npm ERR! Please try running this command again as root/Administrator.  npm ERR! System Darwin 12.0.0 npm ERR! command "node" "/usr/local/bin/npm" "install" "npm" "install" "jasmine-node" "-g" npm ERR! cwd /Users/psanker/Google Drive/Coding/Javascript/WhatsGoingOn npm ERR! node -v v0.8.17 npm ERR! npm -v 1.2.0 npm ERR! path /usr/local/lib/node_modules/npm npm ERR! code EACCES npm ERR! errno 3 npm ERR! stack Error: EACCES, unlink '/usr/local/lib/node_modules/npm' npm ERR!  npm ERR! Additional logging details can be found in: npm ERR!     /Users/psanker/Google Drive/Coding/Javascript/WhatsGoingOn/npm-debug.log npm ERR! not ok code 0 

Now when I try and run

npm install jasmine-node -g 

I get

-bash: /usr/local/bin/npm: No such file or directory 

What's going on?

like image 588
praks5432 Avatar asked Mar 26 '13 09:03

praks5432


People also ask

Why my npm is not working?

If your npm is broken: On Mac or Linux, reinstall npm. Windows: If you're on Windows and you have a broken installation, the easiest thing to do is to reinstall node from the official installer (see this note about installing the latest stable version).

How do you fix npm install not working?

The npm command not found error js server, which you can download from the nodejs.org website. Once you downloaded and installed Node. js, open the terminal and run the npm -v command. Once you see the npm version, you should be able to run the npm install command again.

Is npm 6 still supported?

npm will continue to support any major version of npm as long as it shipped with a version of node that is still supported. So they will support npm@6 until 14 goes EOL because npm@6 shipped with version 14.


1 Answers

When you run npm install -g somepackage, you may get an EACCES error asking you to run the command again as root/Administrator. It's a permissions issue.

It's easy to fix, open your terminal (Applications > Utilities > Terminal)

sudo chown -R $USER /usr/local 

** I strongly recommend you to not use the package management with sudo (sudo npm -g install something), because you can get some issues later **

Reference: http://foohack.com/2010/08/intro-to-npm/

** Update **

The reason is because this can cause permissions problems with lots of other apps, so I'd suggest not doing this.

A better solution when you are installing globally:

sudo chown -R `whoami` ~/.npm 
like image 140
Juancarlos Rodríguez Avatar answered Sep 29 '22 07:09

Juancarlos Rodríguez