Jenkins无法在从节点上运行npm命令,尽管从节点已安装nodejs。

huangapple go评论78阅读模式
英文:

Jenkins unable to run npm command on slave, though slave has nodejs installed

问题

我必须在 Jenkins 从 Git 仓库克隆后在 Jenkins 从属节点上运行 npm install。但是 Jenkins 报错,我无法理解。

Node.js 已安装在我的 Windows 从属节点上,也已添加到 PATH 环境变量中。
在 Jenkins 上,我已安装了 Node.js 插件。我还在作业中勾选了以下选项。请有人帮我看看这里有什么问题。

英文:

I have to run npm install on the jenkins slave once it clones the git repo. But jenkins is giving some weird error, I am unable to understand.

Jenkins无法在从节点上运行npm命令,尽管从节点已安装nodejs。

Nodejs is installed on my windows slave. It is also there in the path.
On jenkins I have the nodejs plugin installed. I also have below option checked in the job. Can anyone please help me with what is wrong here.

Jenkins无法在从节点上运行npm命令,尽管从节点已安装nodejs。

答案1

得分: 0

文档 看来,NodeJS 安装需要设置为 "将其 bin/ 文件夹提供给 PATH"。也许是因为您在 NodeJS 插件中选中了此选项,但没有提供任何内容,所以您会收到 null 错误?

英文:

From the doc it seems that the NodeJS installation needs to be set to "provide its bin/ folder to the PATH". Perhaps it is because you have checked this option in the NodeJS plugin and not provided anything, you get the null error?

答案2

得分: 0

"The 'Provide Node & npm bin/ folder to the PATH' is to offer a Node.js from master to slave, this requires

  1. prepare Node.js Installation on master
  2. enter 'Manage Jenkins' with Jenkins admin to config the Installation then

Then in your job configuration you can choose the pre-configured installation from the dropdown list.

If you have pre-installed Node.js on slave and node binary in PATH, you no need to rely on 'Provide Node & npm bin/ folder to the PATH', just execute node cmd directly.

FYI, config node binary in system environment PATH, in case Jenkins job run as another user, but the user has node binary in PATH."

英文:

The "Provide Node & npm bin/ folder to the PATH" is to offer a Nodejs from master to slave, this requires

  1. prepare Nodejs Installation on master
  2. enter 'Manage Jenkins' with Jenkins admin to config the Installation then

Then in your job configuration you can choose the pre-configured installation from the dropdown list.

If you have pre-installed Nodejs on slave and node binary in PATH, you no need to rely on "Provide Node & npm bin/ folder to the PATH", just execute node cmd directly.

FYI, config node binary in system environment PATH, in case Jenkins job run as another user, but the user has node binary in PATH.

huangapple
  • 本文由 发表于 2023年6月29日 22:10:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/76581859.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定