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.
sudo npm install -g npm)sudo npm cache clear)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 ran into a similar problem,
npm cache clean
solved it.
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.
[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 ~/.npm
npm 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 clean
sudo npm cache clean
I was getting this error on npm install and adding .npmignore did not solve it.
Error: ENOENT, stat 'C:\Users\My-UserName\AppData\Roaming\npm'
I tried going to the mentioned folder and it did not exist. The error was fixed when I created npm folder in Roaming folder.
This is on Windows 8.1
I think your compiled coffee script is missing from the published npm package. Try writing a prepublish command.
In my case (multiple code ENOENT errno 34) problem was with ~/.npm/ directory access. Inside it there were some subdirs having root:root rights, which were causing problems while I run commands as normal user (without sudo). 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).
$ sudo chown yourusername.yourgroupname ~/.npm/ -R
You should know your user name, right? If no then run $ whoami and substitute your group name with it too, like this:
$ sudo chown johnb.johnb ~/.npm/ -R
EDIT:
Test case:
From my local account /home/johnb I npm-installed globally some generator for yeoman, like this:
$ sudo npm install -g generator-laravel
Problem nature:
Above action caused some dependencies being installed inside ~/.npm/ dir, having root:root ownership (because of sudo ...). 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 with sodo (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.
The same error during global install (npm install -g mymodule) for package with a non-existing script.
In package.json:
...
"bin": {
"module": "./bin/module"
},
...
But the ./bin/module did not exist, as it was named modulejs.
I tried all the stuff I found on the net (npm cache clear and rm -rf ~/.npm), but nothing seems to work. What solved the issue was updating node (and npm) to the latest version. Try that.
I got this error while trying to install a grunt plugin. i found i had an outdated version of npm and the error went away after updating npm to the latest version
npm install -g npm
I had a similar issue with a different cause: the yo node generator had added "files": ["lib/"] to my package.json and because my cli.js was outside of the lib/ directory, it was getting skipped when publishing to npm.
(Yeoman issue at https://github.com/yeoman/generator-node/issues/63 it should be fixed soon.)
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
I got a similar error message when trying to npm install a bunch of dependencies. Turns out some of them fail to install on Debian/Ubuntu because they expect /usr/bin/node to be the node executable. To fix, you need do
sudo ln -s nodejs /usr/bin/node
or better yet,
sudo apt-get install nodejs-legacy
For more info: http://stackoverflow.com/a/21171188/7581
I had the same problem, and just found a handling not mentioned here. Though I'd contribute to the community:
npm install -g myapp was not copying the bin directory. I found this to be because I did not include it in the files in my package.json
"files": [
"lib",
"bin" // this was missing
]
In Windows I had a similar error.
Search paste App Data and search for the string npm.
I replaced the string 'npm' (including quotes) with 'npm.cmd' in both atlasboard\lib\package-dependency-manager.js and atlasboard\lib\cli\commands.js. That fixed the problem.
Please try this
SET HTTP_PROXY= Then try that command.It will work