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

npx create-eth@latest fails on node v20+ #49

Closed
technophile-04 opened this issue Jun 13, 2024 · 2 comments
Closed

npx create-eth@latest fails on node v20+ #49

technophile-04 opened this issue Jun 13, 2024 · 2 comments
Assignees

Comments

@technophile-04
Copy link
Collaborator

technophile-04 commented 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:

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:

Screenshot 2024-06-13 at 11 16 09 PM

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

@technophile-04 technophile-04 changed the title npx create-eth@latest fails on node v20+ npx create-eth@latest fails on node v20+ Jun 13, 2024
@technophile-04 technophile-04 self-assigned this Jun 13, 2024
@technophile-04
Copy link
Collaborator Author

Fixed at #51

@djcsdy
Copy link

djcsdy commented Jul 18, 2024

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

2 participants