我试图在我的 Linux centos 机器上运行 npm install
作为 jenkins
但它失败了:
npm WARN tar ENOENT: no such file or directory, lstat '/home/jenkins/workspace/'job name'/Scheduler/scheduler-component/node_modules/ "
但是,如果我以 root
身份运行 npm install
,则一切正常。
为什么会发生这种情况,我该如何解决?
最佳答案
与 $PATH 和 Global/Local 相关的问题,npm 期望它存在但它不存在,使用根 $PATH 以 root 身份运行所以文件存在,npm
It means that when doing something like fs.lstat('/home/ubuntu/.npm/iconv-lite/0.2.11/package/encodings/table/gbk.js', ...), npm received ENOENT error. Which means the file was missing, but npm expected it to be there.
如果没有尝试:
- 确保在 package.json 中正确描述依赖项只需键入 npm 安装并按 Enter。
- 检查问题仍然存在。如果问题 没有解决,继续这些方法。
- 键入 npm cache clean 和 按 Enter 键入 sudo npm install -g npm 并按 Enter。
- 重试 npm 安装并按 Enter。
关于node.js - npm install 命令作为 root 用户工作正常,但如果命令作为 jenkins 用户执行则抛出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51417518/