簡體   English   中英

VS 代碼:NPM 在命令行中運行良好,但“NPM 腳本”窗格獲取“/bin/sh: 1: npm: 未找到”

[英]VS Code: NPM Works Great at the Command Line, but “NPM Scripts” Pane Gets “/bin/sh: 1: npm: not found”

我的(Linux)系統上安裝了 Node/NPM。 當我使用普通終端或 VS Code 中的終端時,我可以很好地運行npm命令。

但是,當我嘗試使用 VS Code 的“NPM 腳本”功能(它允許您從“資源管理器”的窗格中運行package.json腳本)時,我看到:

> 在 MyProject 文件夾中執行任務:npm 運行開始 <

/bin/sh:1:npm:未找到終端進程以退出代碼終止:127

終端將被任務重用,按任意鍵關閉它。

似乎 VS Code 使用不同的用戶/shell/路徑/東西來運行這些腳本,因此它找不到npm命令......但我不知道它在使用什么或如何修復它。

由於某種原因,“NPM 腳本” function 需要 npm 文件位於/usr/local/bin/npm中。 Try using your linux package manager to install npm (ex: sudo apt-get install npm) or install node.js again with the package from the website.

另一種選擇是在/usr/local/bin/中創建指向當前安裝的軟鏈接。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM