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
The same error during global install (
npm install -g mymodule
) for package with a non-existing script.In package.json:
But the
./bin/module
did not exist, as it was namedmodulejs
.I had a similar issue with a different cause: the
yo node
generator had added"files": ["lib/"]
to mypackage.json
and because mycli.js
was outside of thelib/
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.)
Be careful with invalid values for keys "directories" and "files" in package.json
If you start with a new application, and you want to start completely blank, you have to either start in a complete empty folder or have a valid package.json file in it.
If you do not want to create a package.json file first, just type:
npm i some_package
Package with name "some_package" should be installed correctly in a new sub folder "node_modules".
If you create a package.json file first, type:
npm init
Keep all the defaults (by just clicking ENTER), you should end up with a valid file.It should look like this:
Note that the following keys are missing: "directories", "repository" and "files". It looks like if you use incorrect values for "directories" and/or "files", you are not able to install the package. Leaving these keys out, solved the issue for me.
Also note key "main". This one is present, but it does contain an invalid value. No file "index.js" exists (yet). You can safely remove it.
Now type:
npm i some_package
and package with name "some_package" should be installed correctly in a new sub folder "node_modules".If you tried to "make install" in your project directory with this error you can try it:
then you can try to "make install"
If you have the "npm ERR! enoent ENOENT: no such file or directory, chmod '.../djam-backend/node_modules/js-beautify/js/bin/css-beautify.js'" then you can try to install some previous version of the js-beautify, more comments: https://github.com/beautify-web/js-beautify/issues/1247
and the run "make install". It seem works in case if you have not other dependencies that requires higher version (1.7.0) in this case you must downgrade this packages also in the packages.json.
or
None of the above worked for me. But
yarn install
worked, thennpm i
started working. Not sure what yarn fixed, but quick and easy solution!I have a similar problem specifucally : ERR! enoent ENOENT: no such file or directory, chmod 'node_modules/npm/node_modules/request/node_modules/http-signature/node_modules/sshpk/bin/sshpk-conv I tried all above solutions but no luck. I was using vagrant box, and the project was in a shared folder. The problems seems to be only there, when I move the project to another not shared folder (woth host), voila! problem solved. Just in case another person was using also vagrant