node.js npm 安装错误,错误:ENOENT,chmod
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17990647/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
npm install errors with Error: ENOENT, chmod
提问by giodamelio
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 模块。每次我尝试从 npm 或文件夹安装时,都会收到此错误。
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! <[email protected]>
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 并且我已经三重检查了包中的所有内容,一切正常。我四处搜索,看到了几个类似的案例,但没有一个得到解决。这是我尝试过的。
- Upgrade npm (
sudo npm install -g npm) - Clear the global npm cache (
sudo npm cache clear) - Clear the user npm cache (
npm cache clear)
- 升级 npm (
sudo npm install -g npm) - 清除全局 npm 缓存 (
sudo npm cache clear) - 清除用户 npm 缓存 (
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.jshas normal permissions, and npm has superuser permissions during this install.
我注意到错误与我链接到路径的文件有关,特别是当 npm 尝试执行 chmod 时。这应该不是问题,我的lib/cli.js权限是正常的,而 npm 在此安装过程中具有超级用户权限。
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.
在深入了解 npm 文档后,我找到了一个选项,可以阻止 npm 生成 bin 链接(--no-bin-links),当我尝试使用它进行安装时,它运行良好。
So what's the deal? Is this some weird fringe case bugthat has no solution yet?
那么有什么关系呢?这是一些还没有解决方案的奇怪的边缘案例错误吗?
Edit: For reference, hereis the module I uploaded
编辑:供参考,这是我上传的模块
回答by badsyntax
Ok it looks like NPM is using your .gitignoreas a base for the .npmignorefile, and thus ignores /lib. If you add a blank .npmignorefile into the root of your application, everything should work.
好的,看起来 NPM 正在使用您.gitignore作为.npmignore文件的基础,因此忽略/lib. 如果您.npmignore在应用程序的根目录中添加一个空白文件,则一切正常。
[edit] - more info on this behaviour here: https://docs.npmjs.com/misc/developers#keeping-files-out-of-your-package
[编辑] - 有关此行为的更多信息:https: //docs.npmjs.com/misc/developers#keeping-files-out-of-your-package
回答by Genjuro
I ran into a similar problem,
我遇到了类似的问题,
npm cache clean
solved it.
解决了。
回答by Vijay Vepakomma
I was getting this error on npm install and adding .npmignore did not solve it.
我在 npm install 上遇到这个错误,添加 .npmignore 并没有解决它。
Error: ENOENT, stat 'C:\Users\My-UserName\AppData\Roaming\npm'
错误: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 creatednpmfolder in Roamingfolder.
我尝试转到提到的文件夹,但它不存在。当我在Roaming文件夹中创建npm文件夹时,该错误已修复。
This is on Windows 8.1
这是在 Windows 8.1 上
回答by user1978019
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
当我尝试在 Mac 上运行npm install -g bower. 它给了我一些错误,因为我无法找到优雅的 fs 之类的东西。我不确定我最初是如何安装 npm 的,但看起来它可能与使用自制软件的节点有关。我第一次跑
brew uninstall node
This removed both nodeand npmfrom my path. From there I just reinstalled it
这从我的路径中删除了node和npm。从那里我刚刚重新安装了它
brew install node
When it completed I had nodeand npmon my path and I was able to run
当它完成了我node和npm我的道路,我是能够运行
rm -rf ~/.npm
npm install -g bower
This then installed bower successfully.
这样就成功安装了 bower。
Updating the brew formulas and upgrading the installs didn't seem to work for me, I'm not sure why. The removal of the .npmfolder 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:
更新 brew 公式和升级安装似乎对我不起作用,我不知道为什么。.npm文件夹的删除对其他人有用,我尝试过但没有成功。我这次是为了以防万一。另请注意,以下任何一项都没有为我解决问题,尽管对其他人解决了:
npm cache clean
sudo npm cache clean
回答by g.carey
I was getting a similar error on npm installon a local installation:
我npm install在本地安装上遇到了类似的错误:
npm ERR! enoent ENOENT: no such file or directory, stat '[path/to/local/installation]/node_modules/grunt-contrib-jst'
I am not sure what was causing the error, but I had recently installed a couple of new node modules locally, upgraded node with homebrew, and ran 'npm update -g'.
我不确定是什么导致了错误,但我最近在本地安装了几个新的节点模块,使用自制软件升级了节点,并运行了“npm update -g”。
The only way I was able to resolve the issue was to delete the local node_modules directory entirely and run npm installagain:
我能够解决该问题的唯一方法是完全删除本地 node_modules 目录并npm install再次运行:
cd [path/to/local/installation]
npm rm -rdf node_modules
npm install
回答by joaco1977
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
我特别有类似的问题:ERR!enoent ENOENT:没有这样的文件或目录,chmod 'node_modules/npm/node_modules/request/node_modules/http-signature/node_modules/sshpk/bin/sshpk-conv 我尝试了上述所有解决方案,但没有运气。我正在使用 vagrant box,该项目位于共享文件夹中。问题似乎只在那里,当我将项目移动到另一个非共享文件夹(主机)时,瞧!问题解决了。以防万一另一个人也在使用 vagrant
回答by dthree
I had the same problem, and just found a handling not mentioned here. Though I'd contribute to the community:
我遇到了同样的问题,刚刚发现这里没有提到的处理。虽然我会为社区做出贡献:
npm install -g myappwas not copying the bindirectory. I found this to be because I did not include it in the filesin my package.json
npm install -g myapp没有复制bin目录。我发现这是因为我没有将它包含files在我的package.json
"files": [
"lib",
"bin" // this was missing
]
回答by itsadok
I got a similar error message when trying to npm installa bunch of dependencies. Turns out some of them fail to install on Debian/Ubuntu because they expect /usr/bin/nodeto be the node executable. To fix, you need do
尝试npm install一堆依赖项时,我收到了类似的错误消息。事实证明,其中一些无法在 Debian/Ubuntu 上安装,因为它们希望/usr/bin/node成为节点可执行文件。要修复,你需要做
sudo ln -s nodejs /usr/bin/node
or better yet,
或者更好,
sudo apt-get install nodejs-legacy
For more info: https://stackoverflow.com/a/21171188/7581
回答by Prabhu Murthy
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
尝试安装 grunt 插件时出现此错误。我发现我有一个过时的 npm 版本,在将 npm 更新到最新版本后错误消失了
npm install -g npm
回答by leeway
I think your compiled coffee script is missing from the published npm package. Try writing a prepublishcommand.
我认为已发布的 npm 包中缺少您编译的咖啡脚本。尝试编写一个预发布命令。

