-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
fix(npm): Support running npm lifecycle scripts with global resolver #24735
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we should do this for two reasons:
- Running lifecycle scripts in the global cache impacts all projects. I think we should leave the global cache the same way that it was downloaded. If we don't, it may lead to confusion because the cache state evolves over time.
- Not all, but many lifecycle scripts do things like inspecting the node_modules directory structure or installing stuff. For example, sometimes packages look at what other dependencies are in the node_modules directory and do stuff based on that.
So I think we should require a node_modules directory if someone wants to run lifecycle scripts. It's true that this may net make more things work though.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One idea we may want to consider is creating a folder in the cache directory beside the package folder and have the new folder contain the original package. Then we run install scripts in the original folder. Then if someone is using a node_modules directory, we always pull from the cache folder with the original package instead of the one that had post-install scripts run in it.
That said, I'm still a bit concerned about some post install scripts causing havoc in the global cache and the fact that it affects all programs. Maybe not a big deal though?
This also affecting the global state of how Deno works across all programs is also not too great, but it's maybe better than not working at all (though that may lead to confusion when something doesn't work on one person's machine or the CI, but it does on another).
FYI: Another package that needs to run lifecycle scripts is |
9677421
to
d2f4a9f
Compare
Closing in favor of #25786 |
Closes #16164
This PR adds support for running lifecycle scripts when using the global npm resolver. This allows you to run packages like duckdb (or other install script dependent packages) without having to use a node modules dir.
I only copied two of the tests over because the local and global resolver use pretty much the same code for the script execution.