npm install errors with Error: ENOENT, chmod
Ok it looks like NPM is using your .gitignore
as a base for the .npmignore
file, and thus ignores /lib
. If you add a blank .npmignore
file into the root of your application, everything should work.
A better, more explicit approach is to use an allow-list rather than a disallow-list, and use the "files" field in package.json to specify the files in your package.
[edit] - more info on this behaviour here: https://docs.npmjs.com/misc/developers#keeping-files-out-of-your-package
This problem somehow arose for me on Mac when I was trying to run npm install -g bower
. It was giving me a number of errors for not being able to find things like graceful-fs. I'm not sure how I installed npm originally, but it looks like perhaps it came down with node using homebrew. I first ran
brew uninstall node
This removed both node
and npm
from my path. From there I just reinstalled it
brew install node
When it completed I had node
and npm
on my path and I was able to run
rm -rf ~/.npmnpm install -g bower
This then installed bower successfully.
Updating the brew formulas and upgrading the installs didn't seem to work for me, I'm not sure why. The removal of the .npm
folder was something that had worked for other people, and I had tried it without success. I did it this time just in case. Note also that neither of the following solved the problem for me, although it did for others:
npm cache cleansudo npm cache clean