When using the NodeJS tool on a slave that is configured with a global package, the following error is given:
env: can't execute 'node': No such file or directory
If the build runs on an executor in master, there is no error and the package is installed as expected.
I am using the kubernetes plugin with jenkins/jnlp-slave:3.27-1 as the slave image.
Jenkins Version: 2.164.2
Kubernetes Plugin: 1.14.9
NodeJS Plugin: 1.2.9
Note: This is not a duplicate of Jenkins - env: ‘node’: No such file or directory as I am not using the alpine image as was the problem in that question.
Same issue on my Jenkins.
The "download from nodejs.org" installer extracts the node package into a local directory.
It will then run "npm install -g" for each of the packages listed in the "Global npm packages to install" field in the NodeJS installer configuration ("Global tool configuration").
However, it does that before setting the system PATH to the directory where it extracted node, so npm will not find node.
I'm convinced that's a bug in the NodeJS Jenkins plugin. Your options are, as agusluc said, creating a custom jnlp-slave image (which is what I did), or file a bug with the developer of the plugin and hope it will be fixed.
Related
I am trying to run webdriverio test from jenkins and following this . I installed nodeJS plugin for jenkins and under global tool config, for NodeJS , added a name and installation directory as /usr/local/bin (node executable is in this folder)
In Jenkins, in project config , under build environment, I have checked
Provide Node & npm bin/ folder to PATH and chosen the node installation name from previous step
But when I am trying to run npm install
npm test ,by adding these commands under execute shell under Build and building it, I receive this error
Building in workspace /Users/Shared/Jenkins/Home/workspace/wdio-project
[wdio-project] $ /bin/sh -xe /Users/Shared/Jenkins/tmp/hudson1478028169114509075.sh
+ npm install
/Users/Shared/Jenkins/tmp/hudson1478028169114509075.sh: line 2: npm: command not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE
In case someone is looking for same issue, I resolved the above error by adding export PATH=/usr/local/bin to the execute shell under build. This post helped me
There is currently a bug opened about this (JENKINS-26583 and JENKINS-27170)
I could workaround this bug by adding explicitly node on the PATH by adding this line :
export PATH=$PATH:/home/jenkins/.jenkins/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/node_js/bin/
I had just fixed the same issue as you did.
I wonder if my fix would also help you. When I was using the alpine-based docker image, the Jenkins can never find the npm, but when I use the debian-based docker image, problem solved immediately.
Try this export PATH=/usr/local/bin:$PATH
After installation of NodeJS restart pc
In my case this worked -
export PATH=$PATH:/usr/local/bin
I am trying to install the kml branch of Cesium on my local windows machine and I am following instructions to install it from https://github.com/AnalyticalGraphicsInc/cesium/wiki/Contributor's-Guide. I have jdk1.8 installed and node.js installed on my system. I am new to node.js. When I try to build the code I am getting following message. What am I missing in this?
C:\xampp\htdocs\cesium-kmz>.\Tools\apache-ant-1.8.2\bin\ant combine runServer
Buildfile: C:\xampp\htdocs\cesium-kmz\build.xml
build:
checkForNode:
[exec] Execute failed: java.io.IOException: Cannot run program "node": Crea
teProcess error=2, The system cannot find the file specified
BUILD FAILED
C:\xampp\htdocs\cesium-kmz\build.xml:296: Node.js is required to run this part of the build. Install from http://nodejs.org/
Total time: 3 seconds
Thanks in advance!
It looks like the node executable is not in your PATH. Did you select that option at Node install time? Also, did you run npm install successfully before running ant?
I've setup Jenkins v1.550 on Windows Server 2008 R2. It runs as a service at http://localhost:8080 for now. I'm logged into the machine as an Administrator. I've installed Node.js and can run "npm" from the command line.
I've also installed the NodeJS plugin v0.2.1 for Jenkins. I then went into the Configure System section of Jenkins, scrolled down to NodeJS installations, clicked on Add NodeJS button, gave "NodeJS" as the name, and "C:\Program Files\nodejs" as the path to the installation directory. I didn't check the "Install automatically" option as I read on the plugin page that it is only available to Linux.
I then created a new job, clicked the checkbox that said "Provide Node & npm bin/ folder to PATH", created a new build step for "Execute Windows batch command" and typed in "node --version" and "grunt --version" and saved it.
I ran the job and this is the output -
Building in workspace C:\Program Files (x86)\Jenkins\workspace\Test_1.0
[Test_1.0] $ cmd /c call C:\Windows\TEMP\hudson1381541243088903083.bat
C:\Program Files (x86)\Jenkins\workspace\Test_1.0>node --version
v0.10.24
C:\Program Files (x86)\Jenkins\workspace\Test_1.0>grunt --version
'grunt' is not recognized as an internal or external command,
operable program or batch file.
C:\Program Files (x86)\Jenkins\workspace\Test_1.0>exit 9009
Build step 'Execute Windows batch command' marked build as failure
Finished: FAILURE
It looks like it's unable to find the grunt-cli for the user account Jenkins is running under (System). I tried to installing grunt cli globally (npm install -g grunt-cli) and also grunt locally (npm install grunt). No luck.
Can someone please help?
for nice easy to configure self-installed nodejs on the machine, i have to recommend the excellent -> http://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin
it will install nodejs and grunt on the machine, through easy to use web front end no shell required
jenkins jobs can then simply run nodejs build steps, hey presto
steps involved :
a) install this on your jenkins instance -> http://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin
b) create a nodejs installation on jenkins
go to
http://URL_OF_JENKINS/jenkins/configure
NodeJS- > NodeJS installations -> Add NodeJS -> Name = "NodeJS 0.11.10", tick "Install automatically", select "Install from nodejs.org", add "grunt-cli" to globally installed packages
c) create a job with "execute NodeJS script" build task
var sys = require('sys');
sys.puts('NodeJS Test');
sys.puts('***************');
sys.puts('helloworld');
volia :)
run the job and see the nodejs script run,
from their the world is your oyster you can use grunt by ticking "Provide Node/npm bin folder to PATH" and running a "execute shell" build task
npm update
grunt
grunt --force reporting
You will need to restart the Jenkins service after installing node, presumably to cause it to refresh its cached copy of your PATH environment variable
I have grunt doing some tasks for me in Jenkins, but I went the npm script route. Grunt and grunt-cli are dev dependencies, and I have the following defined in my package.json file:
"scripts": {
"test": "node node_modules/grunt-cli/bin/grunt test"
},
In Jenkins (running on Windows), I added two post-build tasks:
npm install
npm test
We just installed NodeJs normally on the Jenkins server.
Another solution that worked for me on Windows is to use the full path to the grunt exec file, which can be found by writing "where grunt" in the command shell. I used the full path in the regular bat-file.
Had the same issue on Windows. When I manually installed node and ran npm install -g grunt-cli from command line, jenkins could not recognize the grunt command. So uninstall node, reinstall it but dont run npm install. Then restart the jenkins slave. Then from the jenkins job that runs on your specific jenkins slave, make it run a Windows batch command that runs npm install -g grunt-cli After that again restart the jenkins service. Then from the job run npm install. Then everything worked for me. If issues still persist, then uninstall the slave, and reinstall it, then everything works fine immediately.
I am using the Eb Command Line Interface to deploy a node.js project to AWS Elastic Beanstalk. I am using git for version control. So the command I run to deploy is simply 'git aws.push'.
Locally, I am using grunt to compile css files from less files and also minify and cmobine js files.
I don't want to include the *.min.css files or *.min.js files in my git repository but would rather have them recompiled on AWS after deployment.
Is there a way to do this? Maybe with a .ebextensions hook or something?
I am not familiar with grunt, but I guess what you would have to do is install nodejs and grunt on elastic beanstalk and then running your grunt commands once the container is set up.
In a ebextensions hook such as .ebextensions/grunt.config you could do the following :
commands:
01-install-nodejs-npm:
command: "yum install -y --enablerepo=epel nodejs npm"
02-install-grunt:
command: "npm install -g grunt-cli"
container_commands:
01-compilecss-minifyjs:
command: "grunt build mytask"
leader_only: true
The commands would make sure nodejs, npm and grunt are installed. The container_commands are executed from within your repository's home directory, so the "source" files for your grunt build should be available from there.
Again - I don't work with grunt and can't tell if this would actually work, but I hope it helps anyway.
I'm using Testacular which is a Node.js test runner for Angular/Jasmine. I can run it fine from the command line, but every time I try to run it from Jenkins build steps, it bombs out with all sorts of errors regarding environment variables. I tried the Nodejs plugin for Jenkins, but that's just to run node code snippets. Anyone know of a way to have node apps (eg. Testacular) running test under Jenkins?
You will need to:
have "testacular" as a dependency in your package.json file.
install your dependencies with npm install (do this as a build step)
call it as ./node_modules/.bin/testacular start --single-run
Assuming you have configured testacular to use PhantomJs browsers = ['PhantomJS'];, you just need to have the phantomjs binary in your path or tell testacular where it is located with an environment variable set in your shell:
export PHANTOMJS_BIN=$HOME/local/bin/phantomjs
good news!
" I tried the Nodejs plugin for Jenkins, but that's just to run node code snippets. "
nope!
install the nodejs plugin see instructions here -> NodeJS jenkins plugin broken?
then tick "Provide Node/npm bin folder to PATH" and when running a "execute shell" build task, you can use nodejs, here's a example using grui
npm update
grunt
grunt --force reporting