npm Community Forum (Archive)

The npm community forum has been discontinued.

To discuss usage of npm, visit the GitHub Support Community.

Error installing NPM

mymac:node-image-upload-imgur mymac$ npm install
Unhandled rejection Error: EACCES: permission denied, mkdir '/Users/mymac/.npm/_cacache/index-v5/3c/39'

Unhandled rejection Error: EACCES: permission denied, mkdir '/Users/mymac/.npm/_cacache/index-v5/24/af'

Unhandled rejection Error: EACCES: permission denied, mkdir '/Users/mymac/.npm/_cacache/index-v5/47/4d'

Unhandled rejection Error: EACCES: permission denied, mkdir '/Users/mymac/.npm/_cacache/index-v5/9a/d0'

npm ERR! cb() never called!

npm ERR! This is an error with npm itself. Please report this error at:
npm ERR!     <>

I don’t even know what npm is, but i know i have to install it for something. And when I run # npm install I get the above output in Terminal. I really don’t know how to overcome this issue, I’m new to using Terminal on my Mac. Any help will be appreciated, thank you.

This is likely an issue with folder ownership being broken by past uses of sudo with global installs. This was fixed in: Release: 6.10.2

The quick fix is to reclaim ownership:

sudo chown -R $USER ~/.npm

If you are able to update npm to avoid the problem happening again, upgrade npm and then run the chown again one last time to fix any issues from the upgrade itself. (If you want help with that, let me know what “npm prefix -g” shows.)

mymac:~ mymac$ sudo chown -R $USER ~/.npm
mymac:~ mymac$ npm prefix -g

mymac:node-image-upload-imgur mymac$ npm install
npm WARN deprecated jade@1.11.0: Jade has been renamed to pug, please install the latest version of pug instead of jade
npm WARN deprecated constantinople@3.0.2: Please update to at least constantinople 3.1.1
npm WARN deprecated transformers@2.1.0: Deprecated, use jstransformer
npm notice created a lockfile as package-lock.json. You should commit this file.
added 135 packages from 166 contributors and audited 221 packages in 11.53s
found 9 vulnerabilities (5 low, 3 moderate, 1 critical)
  run `npm audit fix` to fix them, or `npm audit` for details

mymac:node-image-upload-imgur mymac$ npm audit fix
+ morgan@1.9.1
+ body-parser@1.19.0
+ express@4.17.1
added 4 packages from 4 contributors, removed 7 packages and updated 18 packages in 9.326s
fixed 5 of 9 vulnerabilities in 221 scanned packages
  4 vulnerabilities required manual review and could not be updated

Above are the steps I have just taken, I hope it helps understanding what I’m doing. I’m just trying to install npm for node-image-upload-imgur an Imgur Uploader. However, I do have npm installed elsewhere, but the original command that node-image-upload-imgur uses appears to have a && npm install into the node-image-upload-imgur directory. I have no idea why, however.

Looks fine. Note that the “npm install” is telling npm to install the dependencies for node-image-upload-imgur, not to install npm itself.

Instructions to update npm, and fix permissions one last time:

sudo npm install -g npm@latest
sudo chown -R $USER ~/.npm

Done, thank you very much.

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /Users/mymac/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/Users/mymac/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/mymac/.npm/_logs/2019-09-16T06_42_58_861Z-debug.log

Sorry to bother you again … in order to start node-image-upload-imgur I have to run the command $ npm start the above output is the result I receive, and the imgur upload page does not work as a result. Any tips for a solution? Thanks for your help so far, appreciated.

You run npm start from the package directory, the same directory you ran npm install. (It looks like might be running it from your home folder.)

Excellent, thank you, its working.