Visual Studio代码-使用NPM脚本时找不到NPM

问题描述 投票:3回答:1

如果我打开集成终端并运行npm -v,它将起作用。

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLmltZ3VyLmNvbS96SVRWZVJQLnBuZyJ9” alt =“正在使用”>

但是,如果我直接从NPM SCRIPTS运行它,将无法正常工作。

<< img src =“ https://image.soinside.com/eyJ1cmwiOiAiaHR0cHM6Ly9pLmltZ3VyLmNvbS9tVGpmanlNLnBuZyJ9” alt =“不起作用”>

评论中有更多详细要求

//由Fogmeister编辑

我也有这个问题,这里有更多详细信息...

我在test中定义了一个package.json脚本...

enter image description here

[当我使用npm run test从根文件夹命令行运行此脚本时,它起作用...

enter image description here

此脚本出现在VS Code中的NPM脚本列表中...

enter image description here

当我从NPM Scripts Explorer运行时,它失败了...

enter image description here

即使它说它正在同一文件夹中运行。

npm visual-studio-code npm-scripts
1个回答
0
投票

尝试做,使用dnf或apt-get

sudo apt-get/dnf install npm

npm文件应位于/ usr / local / bin / npm中。如果不存在,请使用其网站上的软件包再次安装node.js。

© www.soinside.com 2019 - 2024. All rights reserved.