### OPTION 1:
Don't use the Npm environment, use it only as a stepping stone to JavaScript. Pass any parameters you need through Npm to your Javascript.
e.g.
In your package.json scripts section:
"scripts": {
"build": "cross-var node env/build.js"
}
build script defined to run javascript under node - optional use of the cross-var package to help it work on windows
(https://www.npmjs.com/package/cross-var)
To invoke on the command line:
npm run build -- <YourFirstArgHere>
Note space after --
To access in your javascript:
let firstParm = process.argv[2]
### OPTION 2:
Use standard environment variables to capture "Start state" mentioned above (Jun21).
(NOTE: I have not tried this technique, and am not sure if the environment variable value will persist between preScript - Script and postScript npm executions - assuming folks know about this: https://docs.npmjs.com/cli/v7/using-npm/scripts/)
Details on Setting these environment variables here:
How to set environment variables from within package.json?
Of particular interest is comment 14:
if you want to use the env var inside the script itself you need to prepend $, for example if you run mode=prod npm run print and you have a script in your package.json called print "print": "echo environment '$mode'" it will print environment 'prod' – Jonathan Morales Vélez