Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with husky install in post install script #373

Open
cole-adams opened this issue Jul 18, 2023 · 10 comments
Open

Issue with husky install in post install script #373

cole-adams opened this issue Jul 18, 2023 · 10 comments

Comments

@cole-adams
Copy link

I'm attempting to upgrade to the latest version of this package, and I'm getting the following error:

npm ERR! code 127
npm ERR! path <project>/node_modules/add-asset-html-webpack-plugin
npm ERR! command failed
npm ERR! command sh -c husky install
npm ERR! sh: husky: command not found

We don't use husky in our project. I notice the post install script for this package is husky install which I believe is no longer best practice for husky.

Is there any way to resolve this?

@cole-adams cole-adams changed the title Issue with package installation Issue with husky install in post install script Jul 18, 2023
@louishust
Copy link

louishust commented Oct 20, 2023

I encounter almost the same problem.

7692 timing command:install Completed in 40492ms
7693 verbose stack Error: command failed
7693 verbose stack     at ChildProcess.<anonymous> (/Users/loushuai/workspace/testing/metersphere/.node/node/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:53:27)
7693 verbose stack     at ChildProcess.emit (node:events:514:28)
7693 verbose stack     at maybeClose (node:internal/child_process:1105:16)
7693 verbose stack     at Socket.<anonymous> (node:internal/child_process:457:11)
7693 verbose stack     at Socket.emit (node:events:514:28)
7693 verbose stack     at Pipe.<anonymous> (node:net:337:12)
7694 verbose pkgid add-asset-html-webpack-plugin@6.0.0
7695 verbose cwd /Users/loushuai/workspace/testing/metersphere/api-test/frontend
7696 verbose Darwin 23.0.0
7697 verbose node v20.8.1
7698 verbose npm  v10.1.0
7699 error code 1
7700 error path /Users/loushuai/workspace/testing/metersphere/api-test/frontend/node_modules/add-asset-html-webpack-plugin
7701 error command failed
7702 error command sh -c husky install
7703 error husky - .git can't be found (see https://typicode.github.io/husky/#/?id=custom-directory)
7704 verbose exit 1

then when executing npm install , i run git init in the node_modules/add-asset-html-webpack-plugin directory, then npm install success.

Then i remove the whole node_modules directory, and try again, it's supposed to be failed again, but amazing, it success, and i do not known why

@gerhat
Copy link

gerhat commented Oct 30, 2023

Same issue here. I had to downgrade to 3.2.2.

@cha0s
Copy link

cha0s commented Jan 31, 2024

Still happening! Can't even use patch-package. I tried.

This package is completely broken!

@cha0s
Copy link

cha0s commented Jan 31, 2024

For anyone totally lost, the only way to make this package work is to do e.g.

npm install --save-dev husky

in your project. Fortunately, it's a pretty small package!

@SimenB
Copy link
Owner

SimenB commented Jun 12, 2024

Hmm, this shouldn't be an issue as I've got pinst setup. And I can see in the published artifact that postinstall is renamed correctly to _postinstall so that it shouldn't run.

https://www.runpkg.com/?add-asset-html-webpack-plugin@6.0.0/package.json#20

What version are you attempting to install?

@cha0s
Copy link

cha0s commented Jun 13, 2024

Sorry, I'm not using webpack anymore. I'm not sure what the issue is/was.

@zburke
Copy link

zburke commented Jul 16, 2024

In a package with a transitive dependency on ^6.0.0, installation via npm i fails with the following in the error log:

[...]
12243 10583 verbose stack Error: command failed
12244 10583 verbose stack     at promiseSpawn (/Users/zburke/.nvm/versions/node/v20.11.1/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:22:22)
12245 10583 verbose stack     at spawnWithShell (/Users/zburke/.nvm/versions/node/v20.11.1/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:124:10)
12246 10583 verbose stack     at promiseSpawn (/Users/zburke/.nvm/versions/node/v20.11.1/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:12:12)
12247 10583 verbose stack     at runScriptPkg (/Users/zburke/.nvm/versions/node/v20.11.1/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/run-script-pkg.js:77:13)
12248 10583 verbose stack     at runScript (/Users/zburke/.nvm/versions/node/v20.11.1/lib/node_modules/npm/node_modules/@npmcli/run-script/lib/run-script.js:9:12)
12249 10583 verbose stack     at /Users/zburke/.nvm/versions/node/v20.11.1/lib/node_modules/npm/node_modules/@npmcli/arborist/lib/arborist/rebuild.js:329:17
12250 10583 verbose stack     at run (/Users/zburke/.nvm/versions/node/v20.11.1/lib/node_modules/npm/node_modules/promise-call-limit/dist/commonjs/index.js:67:22)
12251 10583 verbose stack     at /Users/zburke/.nvm/versions/node/v20.11.1/lib/node_modules/npm/node_modules/promise-call-limit/dist/commonjs/index.js:84:9
12252 10583 verbose stack     at new Promise (<anonymous>)
12253 10583 verbose stack     at callLimit (/Users/zburke/.nvm/versions/node/v20.11.1/lib/node_modules/npm/node_modules/promise-call-limit/dist/commonjs/index.js:35:69)
12254 10584 verbose pkgid add-asset-html-webpack-plugin@6.0.0
12255 10585 error code 127
12256 10586 error path /Users/zburke/temp/stripes-core/node_modules/add-asset-html-webpack-plugin
12257 10587 error command failed
12258 10588 error command sh -c husky install
12259 10589 error sh: husky: command not found

This package installs cleanly without errors with yarn v1 or with npm i --ignore-scripts. Environment details:

$ uname -a
Darwin LP-C02G8208ML85 23.5.0 Darwin Kernel Version 23.5.0: Wed May  1 20:09:52 PDT 2024; root:xnu-10063.121.3~5/RELEASE_X86_64 x86_64
$ node -v
v20.11.1
$ npm -v 
10.8.2

@SimenB
Copy link
Owner

SimenB commented Jul 16, 2024

mkdir test && cd test && npm init -y && npm install --save-dev add-asset-html-webpack-plugin works fine... Do you have a reproduction?

@zburke
Copy link

zburke commented Jul 17, 2024

@SimenB : Here are reproduction steps:

git clone git@github.com:folio-org/stripes-core.git
cd stripes-core
echo "@folio:registry = https://repository.folio.org/repository/npm-folioci/" >> .npmrc
npm install

add-asset-html-webpack-plugin comes into this package, @folio/stripes-core, transitively through @folio/stripes-cli and @folio/stripes-webpack. I don't think we're doing anything interesting in stripes-webpack; it's just a regular ol' dep in package.json. Our current build pipeline uses yarn v1 but we're trying to migrate back to npm.

@zburke
Copy link

zburke commented Jul 17, 2024

Related issues:

This is strange. It does feel like a bug in NPM >= 10.4.0, but as noted in the npm issue, then its impact should be bigger.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants