In my package.json
, I have several scripts that call node
with the same parameters over and over. To simplify that invocation, I've created a package.json
variable, and am invoking the scripts like this:
{
"nodeParams": "--experimental-specifier-resolution=node --harmony -r source-map-support/register",
"scripts": {
"dothis": "node $npm_package_nodeParams myscript.js",
"dothat": "node $npm_package_nodeParams another-script.js",
...
}
}
This is quite common for calling compiled TypeScript code, and worked fine in NPM v6.
However, it no longer works in NPM v7 due to a breaking change:
RFC 21 Environment no longer includes npm_package_* fields
What is the currently recommended solution, or some alternative?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…