I am trying to globally install an npm module I just published. Every time I try to install, either from npm or the folder, I get this error.
npm ERR! Error: ENOENT, chmod '/usr/local/lib/node_modules/takeapeek/lib/cmd.js'
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 Linux 3.8.0-19-generic
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "takeapeek"
npm ERR! cwd /home/giodamlio
npm ERR! node -v v0.10.6
npm ERR! npm -v 1.3.6
npm ERR! path /usr/local/lib/node_modules/takeapeek/lib/cmd.js
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/giodamlio/npm-debug.log
npm ERR! not ok code 0
I am using sudo and I have triple checked everything in the package everything should work. I did some searching around, and saw a couple of similer cases none of which have been resolved. Here is what I tried.
- Upgrade npm (
sudo npm install -g npm
) - Clear the global npm cache (
sudo npm cache clear
) - Clear the user npm cache (
npm cache clear
)
I noticed that the error had to do with the file I am linking to the path, specifically when npm tried to do a chmod. That shouldn't be a problem, my lib/cli.js
has normal permissions, and npm has superuser permissions during this install.
After digging through the npm docs I found an option that would stop npm from making the bin links(--no-bin-links
), when I tried the install with it, it worked fine.
So what's the deal? Is this some weird fringe case bug that has no solution yet?
Edit: For reference, here is the module I uploaded
I think your compiled coffee script is missing from the published npm package. Try writing a prepublish command.
I encountered similar behavior after upgrading to npm
6.1.0
. It seemed to work once, but then I got into a state with this error while trying to install a package that was specified by path on the filesystem:The following things did not fix the problem:
rm -rf node_modules
npm cache clean
(gavenpm ERR! As of npm@5, the npm cache self-heals
....use 'npm cache verify' instead.
)npm cache verify
rm -rf ~/.npm
How I fixed the problem:
rm package-lock.json
I ran into a similar problem,
solved it.
In my case (multiple code ENOENT errno 34) problem was with
~/.npm/
directory access. Inside it there were some subdirs havingroot:root
rights, which were causing problems while I run commands as normal user (withoutsudo
). So I changed ownership of all subdirs and files inside~/.npm/
dir into my local user and group. That did the trick on my Ubuntu (on Mac should work too).You should know your user name, right? If no then run
$ whoami
and substitute your group name with it too, like this:EDIT:
Test case:
From my local account
/home/johnb
I npm-installed globally some generator foryeoman
, like this:Problem nature:
Above action caused some dependencies being installed inside
~/.npm/
dir, havingroot:root
ownership (because ofsudo ...
). Evidently npm does not run as local user (or change dependencies subdirs ownership afterwards) when pulling dependencies and writing them to a local user subdir~/.npm/
. As long as npm would be so careless against fundamental unix filesystem security issues the problem would reoccur.Solution:
Continuosly check if
~/.npm/
contains subdirs with ownership (and/or permissions) other than your local user account, especially when you install or update something withsodo
(root). If so, change the ownership inside~/.npm/
to a local user recursively.Ask
npm, bower, grunt, ...
community that they address this issue as I described it above.I was getting the error "Error: ENOENT, stat 'C:\Users\userName\AppData\Roaming\npm'. But there was no such directory. Created the directory and the npm install started working