Home > Software engineering >  VS Code how to specify npm run shell per project
VS Code how to specify npm run shell per project

Time:11-14

I'm contributing to a project hosted on GitHub (https://github.com/esphome/dashboard) which is using bash scripts to develop and build.
I'm using Windows 10, so my default shell in VS Code was Command Prompt, I've changed it to Bash, by setting the default profile to Git Bash (and I verified that when I open a new terminal it is bash), but when I run an npm task I'm getting this error:

 *  Executing task: npm run develop 


> [email protected] develop
> script/develop

'script' is not recognized as an internal or external command,
operable program or batch file.

 *  The terminal process "C:\WINDOWS\System32\cmd.exe /d /c npm run develop" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

I can globally set npm config according to this answer by calling:

npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"

but this is a global change and I must remember to revert it by calling:

npm config delete script-shell

Is there a way to set this per project, so that when I open this project it will use bash and when I open others they will use the default (cmd)?

CodePudding user response:

You can put following line :

script-shell=C:\Program Files\git\bin\bash.exe

in your projects-root/.npmrc, and remove it from ~/.npmrc

  • Related