So the problem here is that Node scripts are run using the shell (e.g., cmd.exe on Windows; generally Bash on Linux and Mac) and shells have different languages. So build:prod
runs:
npm run test && npm run build
The npm run test
part works more or less but then it hits the npm run build
which runs:
npm run clean && NODE_ENV="production" webpack --progress --colors
The first part of that works, but the second parts hits the NODE_ENV
part and fails because this is how you set an environment variable on POSIX-compatible shells, but not the Window cmd.exe (the syntax there is set NODE_ENV="production"
).
Here are a few options that will get this working for you:
- If you have Git for Windows installed, just run the
npm run build:prod
command in theGit BASH
emulator. - You can install this Node package, which purports to solve the problem (at least while using cmd.exe and for a limit number of environment variables).
- You can install the Windows Subsystem for Linux and use a real version of Bash (though that’s a bit heavy-weight for just compiling one package).