我正在為 GitHub ( https://github.com/esphome/dashboard ) 上托管的一個專案做貢獻,該專案使用 bash 腳本進行開發和構建。
我使用的是 Windows 10,所以我在 VS Code 中的默認 shell 是命令提示符,我通過將默認組態檔設定為 Git Bash 將其更改為 Bash(并且我驗證了當我打開一個新終端時它是 bash),但是當我運行一個 npm 任務時,我收到了這個錯誤:
* 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.
我可以通過呼叫以下答案根據此答案全域設定 npm config:
npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"
但這是一個全球性的變化,我必須記得通過呼叫來恢復它:
npm config delete script-shell
有沒有辦法為每個專案設定這個,這樣當我打開這個專案時它將使用 bash 而當我打開其他專案時它們將使用默認值(cmd)?
uj5u.com熱心網友回復:
您可以輸入以下行:
script-shell=C:\Program Files\git\bin\bash.exe
在你的 projects-root/.npmrc 中,并將其從 ~/.npmrc 中洗掉
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/533706.html
