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

Options won't work with npm >= 7 #93

Closed
FredericEspiau opened this issue Feb 26, 2021 · 7 comments
Closed

Options won't work with npm >= 7 #93

FredericEspiau opened this issue Feb 26, 2021 · 7 comments

Comments

@FredericEspiau
Copy link

FredericEspiau commented Feb 26, 2021

Hello,

because of RFC21 : https://github.com/npm/rfcs/blob/latest/implemented/0021-reduce-lifecycle-script-environment.md

npm_package_* are no longer exported in the environment variables

No idea what the fix should be

Thanks for the hard and awesome work on this!

@searls
Copy link
Member

searls commented Feb 26, 2021

cc/ @jasonkarns for visibility and/or 🧂

@jasonkarns
Copy link
Member

@searls too late. I was railing about this on Twitter when this behavior was announced (while npm7 was still in beta)

https://twitter.com/JessTelford/status/1258549958728286208
https://twitter.com/jasonkarns/status/1293736534403887106

npm/rfcs#183

@FredericEspiau
Copy link
Author

So, are you going to to something about this ?

@rosston
Copy link
Member

rosston commented Mar 2, 2021

I'm not likely to have time to work on this soon, but I want to note what I've found about fixing this so far.

Here's what I think options compatibility with npm 7 will require:

  • Figure out how to handle implementing and testing this in both npm 6 and 7; npm 6 is still the default for LTS versions of node (v10, v12, and v14 as of this writing), so I think it makes sense to support both versions
  • Code that uses npm_package_scripty_* (just lib/load-option.js) will need to be updated to also/instead use npm_package_json (per the RFC) and then parse the file from that env var to find scripty options
  • Update several test files (lib/load-option.test.js, test/safe/modules-test.js, test/safe/relative-path-loading.js) that specify npm_package_scripty_* env vars to also/instead work based on npm_package_json

@JerryC8080
Copy link

+1

@wroughtec
Copy link

wroughtec commented Dec 3, 2021

Seems to be an even bigger issue with yarn 2+ as currently does not have npm_package_json available

yarnpkg/berry#2436

@rosston
Copy link
Member

rosston commented Apr 8, 2022

This should be resolved in scripty 2.1.0 (via #105). Note that you'll want to put your scripty config underneath a config key, per the updated README. Feel free to comment/reopen if this is not actually fixed!

@rosston rosston closed this as completed Apr 8, 2022
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

Successfully merging a pull request may close this issue.

6 participants