Skip to main content
Code and think

NPM Shell

On Windows, especially, we might want to change the default shell for NPM scripts. The default on Windows is cmd.exe. However, in this modern day and age, pwsh sounds much more appealing.

To modify it for a project, you can add the following to the .npmrc:

...
script-shell=pwsh

It can also be achieved with the following command:

npm config set script-shell pwsh --userconfig ./.npmrc

To modify it globally on the current environment, run the following command:

npm config set script-shell pwsh [--global]

The beauty of PowerShell core is that it is OS-agnostic, so you can use it on different environment. It also supports some bash syntax.

Reference: https://docs.npmjs.com/cli/v8/using-npm/config#script-shell