You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To be more particular it happens when the npm version is 10.4.0 or later.
Hacky solution for now is to run it with --ignore-scripts flag:
npx create-eth@latest --ignore-scripts
or use 18 or below versions of node
Cause:
The main problem is husky.
The thing is that husky doesn't play nicely with yarn v2+ since yarn does not have prepare life cycle method checkout this so we have to rely on postinstall lifecycle as mentioned in the docs checkout #46.
But using postinstall is bad idea because whenever some one does npx create-eth@latest the postinstall script runs and since we have postinstall: husky init it will fail on users computer because while we bundle cli we don't include husky init since it's a dev dependency.
Workaround to above solution was to use pinst which we did in #46, what pinst does is before publishing your package to npm it edit's your package.json and renames postinstall => _postinstall so that it does not runs on users computers.
Example :
You can navigate to ~/.npm/_npx/{id}/node_modules/create-eth/package.json:
Now in ideal world with magic of pinst on users computer we wont run husky init since we renamed it to _postinstall script but the thing is for some wired reason 10.4.0 and later npm cli actually runs _postinstall checkout typicode/pinst#23 and npm/cli#7322
Solution:
Ditch husky since with yarn v2+ it requires addition of postinstall and we don't want to do it since postinstall runs on users computer too, We could move husky from devDependency to dependency but I don't like it and not that worth it.
Use other alternatives on my research I found lefthook to be best, will probably make a PR migrating to it
The text was updated successfully, but these errors were encountered:
technophile-04
changed the title
npx create-eth@latest fails on node v20+
npx create-eth@latest fails on node v20+
Jun 13, 2024
Description :
To be more particular it happens when the npm version is 10.4.0 or later.
Hacky solution for now is to run it with
--ignore-scripts
flag:or use 18 or below versions of node
Cause:
The main problem is
husky
.The thing is that husky doesn't play nicely with yarn v2+ since yarn does not have
prepare
life cycle method checkout this so we have to rely onpostinstall
lifecycle as mentioned in the docs checkout #46.But using
postinstall
is bad idea because whenever some one doesnpx create-eth@latest
thepostinstall
script runs and since we havepostinstall: husky init
it will fail on users computer because while we bundle cli we don't include husky init since it's a dev dependency.Workaround to above solution was to use
pinst
which we did in #46, whatpinst
does is before publishing your package to npm it edit's yourpackage.json
and renamespostinstall
=>_postinstall
so that it does not runs on users computers.Example :
You can navigate to
~/.npm/_npx/{id}/node_modules/create-eth/package.json
:Now in ideal world with magic of
pinst
on users computer we wont runhusky init
since we renamed it to_postinstall
script but the thing is for some wired reason 10.4.0 and later npm cli actually runs_postinstall
checkout typicode/pinst#23 and npm/cli#7322Solution:
Ditch husky since with yarn v2+ it requires addition of
postinstall
and we don't want to do it sincepostinstall
runs on users computer too, We could move husky from devDependency to dependency but I don't like it and not that worth it.Use other alternatives on my research I found lefthook to be best, will probably make a PR migrating to it
The text was updated successfully, but these errors were encountered: