Solve Jenkins report /usr/bin/env: node: No such file or directory

1. Environmental Description

  • CentOS 7.6
  • Jenkins 2.164.3
  • Node 14.13.0

2. Description of the problem

The Node version of the server was originally 10.13.0, and later version 14.13.0 was required to deploy new projects. So uninstall Node globally and install NVM to manage Node. When using Jenkins to build, it happens /usr/bin/env: node: 没有那个文件或目录, as shown below

3. Troubleshooting process

1. Determine whether the server NVM and Node are normal (no problem)

2. Determine whether NVM has automatically created the Node environment variable (no problem)

3. Determine whether the Jenkins execution script recognizes Node (problem)


4. Determine whether the Jenkins execution script recognizes Node Environment variables (problems)


5. After communicating with the operation and maintenance personnel, add the following two commands, which can be executed normally


. Finally, doubts: NVM installation can only be recognized by restarting the terminal. Does Jenkins also need to be restarted to recognize Node? The result is still useless. . .


7. Continue to communicate with the operation and maintenance personnel to source /etc/profileupdate the environment variables, but it is still useless. . .

4. Add environment variables through global properties to identify Node

System Administration > System Settings > Global Properties > Environment Variables

5. Manage and build Node by installing the nvm-wrapper plug-in

Although Jenkins can recognize Node through the export environment variable and the configuration environment in Jenkins, it cannot meet the requirements of using different Node versions for different project versions, but nvm- wrapper can do it

1. Install the nvm-wrapper plugin in Jenkins, System Management > Plugin Management > Optional Plugins

2. Configure the project-level Node version, project (project to be built) > Configuration > NVM Settings

Guess you like

Origin blog.csdn.net/qq_41548644/article/details/118081648