0

I ran into some issue where I ran npm update -g and I'm suddenly not able to use npm (filed an issue here: https://github.com/npm/npm/issues/12135).

I just get the following when I try:

$ npm
-bash: npm: command not found

I'm trying to get back up and running but I'm unable to install it via the command line. I tried using the cURL command listed online and got the following:

$ curl https://npmjs.org/install.sh | sudo sh

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   193  100   193    0     0    422      0 --:--:-- --:--:-- --:--:--   422
sh: line 1: html: No such file or directory
sh: line 2: syntax error near unexpected token `<'
'h: line 2: `<head><title>301 Moved Permanently</title></head>

When I moved the sudo to the front of the line, I got the following:

sudo curl -L https://www.npmjs.com/install.sh | sh

[some successes here]

npm ERR! Darwin 14.5.0
npm ERR! argv "/usr/local/bin/node" "/private/var/folders/7z/khvfflqx5k59v2lhlxkpnq4w0000gp/T/npm.44471/package/cli.js" "install" "-gf"
npm ERR! node v4.2.1
npm ERR! npm  v3.8.5
npm ERR! path /usr/local/lib/node_modules/npm/node_modules/normalize-package-data/node_modules/is-builtin-module/node_modules/builtin-modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall rename

npm ERR! Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/npm/node_modules/normalize-package-data/node_modules/is-builtin-module/node_modules/builtin-modules' -> '/usr/local/lib/node_modules/npm/node_modules/normalize-package-data/node_modules/is-builtin-module/node_modules/.builtin-modules.DELETE'
npm ERR!     at moveAway (/private/var/folders/7z/khvfflqx5k59v2lhlxkpnq4w0000gp/T/npm.44471/package/lib/install/action/finalize.js:38:5)
npm ERR!     at destStatted (/private/var/folders/7z/khvfflqx5k59v2lhlxkpnq4w0000gp/T/npm.44471/package/lib/install/action/finalize.js:27:7)
npm ERR!     at FSReqWrap.oncomplete (fs.js:82:15)
npm ERR!
npm ERR! Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/npm/node_modules/normalize-package-data/node_modules/is-builtin-module/node_modules/builtin-modules' -> '/usr/local/lib/node_modules/npm/node_modules/normalize-package-data/node_modules/is-builtin-module/node_modules/.builtin-modules.DELETE'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES: permission denied, rename '/usr/local/lib/node_modules/npm/node_modules/normalize-package-data/node_modules/is-builtin-module/node_modules/builtin-modules' -> '/usr/local/lib/node_modules/npm/node_modules/normalize-package-data/node_modules/is-builtin-module/node_modules/.builtin-modules.DELETE'] parent: 'is-builtin-module' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /private/var/folders/7z/khvfflqx5k59v2lhlxkpnq4w0000gp/T/npm.44471/package/npm-debug.log
npm ERR! code 1
It failed

I checked and the ~/.npm folder still exists and has its contents, and so does /usr/local/lib/node_modules/. What's going on here? How do I fix this?

Cassidy Williams
  • 2,840
  • 2
  • 34
  • 62

1 Answers1

1

It is caused that you didnt completely uninstall the npm.

Try use rm -rf remove the old folders and then install the npm.

see this would be helpful

Community
  • 1
  • 1
RoyX
  • 52
  • 1
  • 6