[rush] rushx does not support npm environment vars (e.g. npm_package_version)
Summary
I have a create-react-app project with an environment file (.env) that contains the following line:
REACT_APP_VERSION=$npm_package_version
When running npm run start or pnpm run start, the variable gets populated with the correct version number from the package.json. When running rushx start, this does not work. The environment variable stays empty.
Repro steps
Setup a new Rush installation with a single project inside, only containing a package.json with the following contents:
{
"name": "test",
"version": "1.0.0",
"description": "",
"scripts": {
"test": "echo $npm_package_version"
},
"author": "",
"license": "ISC"
}
Then run the following command in that project:
rushx test
Expected result:
$ npm run test
> echo $npm_package_version
1.0.0
Actual result:
$ rushx test
> "echo $npm_package_version"
Details
Standard questions
Please answer these questions to help us investigate your issue more quickly:
| Question | Answer |
|---|---|
@microsoft/rush globally installed version? |
@microsoft/[email protected] |
rushVersion from rush.json? |
5.74.0 |
useWorkspaces from rush.json? |
true |
| Operating system? | Mac Apple Silicon |
| Would you consider contributing a PR? | Yes |
Node.js version (node -v)? |
18.1.0 |
Yeah this is a missing feature. It'd be awesome if you were interested in putting this together.
This is an issue for my team. Weuse $npm_config_... variables in some of our package.json scripts. However, this means that the scripts cannot be run using rushx {scriptName}, but instead must be run as npm run {scriptName}. This feels like we're half in and half out with rushjs.
We would really like to see this feature added to Rush.