gpt4 book ai didi

node.js - npm install 命令作为 root 用户工作正常,但如果命令作为 jenkins 用户执行则抛出错误

转载 作者:太空宇宙 更新时间:2023-11-04 10:07:19 24 4
gpt4 key购买 nike

我试图在我的 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

This Tutorial explains it

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.

如果没有尝试:

  1. 确保在 package.json 中正确描述依赖项只需键入npm 安装并按 Enter。
  2. 检查问题仍然存在。如果问题没有解决,继续这些方法。
  3. 键入 npm cache clean 和按 Enter 键入 sudo npm install -g npm 并按 Enter。
  4. 重试 npm安装并按 Enter。

关于node.js - npm install 命令作为 root 用户工作正常,但如果命令作为 jenkins 用户执行则抛出错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51417518/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com