Node.js projects are very much cross-platform, allowing your team to use any operating system they want to work on them. Well, yes, to a large degree they are; but as always, there are some caveats that can bring some headaches if you have Windows developers in your team.
Environment Variables
When using environment variables like NODE_ENV
in your npm
scripts in Windows, the Git Bash command line interpreter in Windows complains that said NODE_ENV
variable (or any other) “is not a command”. To avoid this problem, use cross-env in the application:
npm install cross-env —save-dev
Now you can use the cross-env
command before any environment variable you need for your npm
scripts, and all operating systems will be happy.
Removing Folders
Use rimraf. Do not hardcode rm -rf
in your npm
script, because that command won’t work on Windows.
npm install rimraf —save-dev
This is particularly useful for your npm run clean
command.