The likely problem is that the space character before &&
becomes part of the environment-variable values, so that the values are staging
and production
- note the trailing space - rather than staging
and production
.
The simplest way to avoid this is to remove the space before &&
(it looks awkward, but it works):
"scripts": {
"start": "SET NODE_ENV=staging&& nodemon app",
"production": "set NODE_ENV=production&& nodemon app",
"test": "echo \"Error: no test specified\" && exit 1"
}
To avoid such problems in general, it's best to assign variable values in cmd.exe
using the form
set "variable=value"
, i.e. to enclose the name, the =
, and the value in "..."
overall, which delimits the value explicitly, irrespective of subsequent (unquoted) whitespace; therefore, the following should work too (with the embedded "
characters escaped as \"
, as required by JSON).
"scripts": {
"start": "SET \"NODE_ENV=staging\" && nodemon app",
"production": "set \"NODE_ENV=production\" && nodemon app",
"test": "echo \"Error: no test specified\" && exit 1"
}