I am trying to set up a pipeline using GoCD. I have a requirement of running npm install and npm test, and so, I created a Pipeline with a single Stage, that has a single Job with two tasks.
When I execute the pipeline, the npm install task seems to fail with the error mentioned below. However, when I manually run npm install from the repository in the agent's folder, it goes through without errors. With GoCD's npm install, I found that almost all packages except 2 seem to be installed. It fails with the follow error, and I suspect this to be some problem with node-gyp.
...
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/glob-watcher/node_modules/fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] install: `node install.js`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: spawn sh ENOENT
npm ERR! file sh
npm ERR! path sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn sh
npm ERR! [email protected] install: `node-gyp rebuild`
npm ERR! spawn sh ENOENT
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
...
I tried using Jenkins and found the same issue. After a lot of deep dives, I found that it had something to do with the Python version being used, which in turn is due to the Node version being used. I was using Node v12.4.0, and upgrading it to Node v14.x.x addressed my issue.