-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[BUG] Package variable replacement in package scripts fails with names containing hyphens #2541
Comments
@roydukkey shell vars don't support dash casing; That said, you can still pull out the env config with something like: "prepack": "node -pe \"process.env['npm_package_bin_my-package']\"" ^ as you alluded to. |
@darcyclarke Sure, but why can't npm interpolate |
@roydukkey I was going to note it would be a breaking change but this truly looks like it inadvertently stopped interpolating between v6 & v7 (ie. it worked differently before, so it's definitely a bug). Apologize for closing so quickly there, I'll reopen & we'll investigate (ref. the value should be |
I was under the impression that virtually all of the npm package env vars were intentionally removed in npm 7, since you can hardcode or read from package.json directly. In this case, probably the simplest would be duplicating the path to the bin. |
@ljharb the RFC that was created last year, about changes to environment variables, specifically outlines that |
@liharb I am specifically trying to avoid duplication. |
Thanks for clarifying, good to know. |
I have the same issue with windows using |
+1 on this |
Current Behavior:
project.json
vars do not work with hyphens withinpackage.json
scripts interpolation.Expected Behavior:
I would expect variable with hyphens which are used from with package script to be properly accessible.
Steps To Reproduce:
package.json
npm run prepack
.process.env
actually passed to the script is as follows:Environment:
The text was updated successfully, but these errors were encountered: