BUG: v2.46.0 introduced a postinstall lifecycle script which requires devdependencies for non-development installations
michael-kirkegaard-solita opened this issue · 4 comments
In version v2.46.0 the package.json file has introduced the lifecycle script postinstall
.
The postinstall
script executes cli commands that requires the packages "peggy" and "mkdirp" to be installed.
The packages "peggy" and "mkdirp" are not defined in the dependencies, only in the devDependencies.
When apigeelint in installed for non-development usage with npm install -g apigeelint@latest
, devDependencies are not installed [1] but the postinstall
script is triggered [2], resulting in the postinstall
script failing because "peggy" and "mkdirp" are not necessarily installed.
This makes the npm install
command fail.
References:
[1]: https://docs.npmjs.com/specifying-dependencies-and-devdependencies-in-a-package-json-file
[2]: https://docs.npmjs.com/cli/v8/using-npm/scripts#npm-install
Yeah, I noticed this too, but I think the actual problem is that the postinstall script is running from the ./node_modules/apigeelint folder and from there it's referencing ./node_modules/peggy/peggy.js. I tried manually adding peggy to my project, but it still failed because the ./node_modules/apigeelint folder didn't have it's own node_modules folder.
Adding an npm i
to the post install script should solve this, but I don't know how clean that would be.
Used npx
to invoke peggy
like was done for mkdirp
. Pull request #408 is ready for this issue
Unpublished v2.46.0
Published v2.46.3
I had to comment out the postinstall script from the package.json as the npx
command was failing when I was trying to install apigeelint globally. Looks like peggy and mkdirp needs to be installed globally for the postinstall command to work?
Please test and see if the issue still persists