1

My JS project uses a NPM package called commitizen: https://github.com/commitizen/cz-cli

commitizen is added to my devDependencies in package.json file. commitizen uses internally a package called opencollective as you can see here: https://github.com/commitizen/cz-cli/blob/master/package.json

commitizen on postinstall hook is calling opencollective postinstall which is supposed to run opencollective package binary.

Locally I've no problems running the postinstall hook, however, when I build my project on my Jenkins CI box I get this error when it runs the postinstall hook of commitizen package

sh: 1: opencollective: not found

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! commitizen@2.10.1 postinstall: `opencollective postinstall`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the commitizen@2.10.1 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

I tried to add node_modules/opencollective/dist/bin dir to the PATH but with no luck, I think because the opencollective alias is defined in opencollective package.json

Any idea about how to be able to run opencollective command without installing globally opencollective package?

Thank you!

antzshrek
  • 9,276
  • 5
  • 26
  • 43
gabric
  • 1,865
  • 2
  • 21
  • 32
  • Have you installed *commitizen* globally? – Talha Junaid Aug 31 '18 at 20:34
  • 1
    please check a file named `opencollective` exists in `node_modules/.bin`, if not, means the npm package opencollective install failed. then when commitizen call `opencollective postinstall`, it can't find `opencollective` from `node_modules/.bin`. If so, you can install `opencollective` in advance by run `npm i opencollective` under project folder to check it can be install successfully, then run `npm install` – yong Sep 01 '18 at 02:28
  • It can't be installed globally since it's a Ci machine and I don't have control over it – gabric Sep 01 '18 at 09:21
  • @yong Thanks for your comment. I've checked and there is an `opencollective` alias in `node_modules/.bin` directory. So what was missing is to tell Jenkins to add that directoty to PATH. That can be done by simply adding the following `:${env.WORKSPACE}/node_modules/.bin` to PATH configuration in `Jenkinsfile` file – gabric Sep 03 '18 at 07:40
  • @gabric, I think we no need to append `${env.WORKSPACE}/node_modules/.bin` too `PATH`, i can install `commitizen` successfully on my Mac with out appending it to `PATH`. Could you show the shell used to install packages for project in your jenkins job – yong Sep 03 '18 at 08:29

0 Answers0