npm 安装错误,错误:ENOENT,chmod [英] npm install errors with Error: ENOENT, chmod

查看:37
本文介绍了npm 安装错误,错误:ENOENT,chmod的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试全局安装我刚刚发布的 npm 模块.每次我尝试从 npm 或文件夹安装时,都会出现此错误.

npm 错误!错误:ENOENT,chmod '/usr/local/lib/node_modules/takeapeek/lib/cmd.js'npm 错误!如果您需要帮助,可以在以下位置报告此日志:npm 错误!<http://github.com/isaacs/npm/issues>npm 错误!或电邮至:npm 错误!<npm-@googlegroups.com>npm 错误!系统 Linux 3.8.0-19-genericnpm 错误!命令节点"/usr/local/bin/npm"安装"-g"takeapeek"npm 错误!cwd/home/giodamlionpm 错误!节点 -v v0.10.6npm 错误!npm -v 1.3.6npm 错误!路径/usr/local/lib/node_modules/takeapeek/lib/cmd.jsnpm 错误!代码 ENOENTnpm 错误!错误号 34npm 错误!npm 错误!可以在以下位置找到其他日志记录详细信息:npm 错误!/home/giodamlio/npm-debug.lognpm 错误!不行 代码 0

我正在使用 sudo 并且我已经三重检查了包中的所有内容,一切正常.我四处搜索,看到了几个类似的案例,但没有一个得到解决.这是我尝试过的.

  • 升级 npm (sudo npm install -g npm)
  • 清除全局 npm 缓存(sudo npm cache clear)
  • 清除用户 npm 缓存(npm cache clear)

我注意到错误与我链接到路径的文件有关,特别是当 npm 尝试执行 chmod 时.这应该不是问题,我的 lib/cli.js 具有正常权限,而 npm 在此安装过程中具有超级用户权限.

在深入了解 npm 文档后,我找到了一个选项,可以阻止 npm 生成 bin 链接(--no-bin-links),当我尝试使用它进行安装时,它运行良好.

那是怎么回事?这是一些尚未解决的奇怪的边缘案例错误吗?>

作为参考,这里是我上传的模块

解决方案

好吧,看起来 NPM 正在使用您的 .gitignore 作为 .npmignore 文件的基础,因此忽略 /lib.如果您将一个空白的 .npmignore 文件添加到应用程序的根目录中,则一切正常.

更好、更明确的方法是使用允许列表而不是禁止列表,并使用文件"列表.package.json 中的字段来指定包中的文件.

- 关于此行为的更多信息:https://docs.npmjs.com/cli/v7/using-npm/developers#keeping-files-out-of-your-package

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

解决方案

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/cli/v7/using-npm/developers#keeping-files-out-of-your-package

这篇关于npm 安装错误,错误:ENOENT,chmod的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆