[英]"npm-run-all" Is Not Recognized As an Internal or External Command
I installed npm-run-all and also configured the environment variable (which may or may not be not required) on my Windows machine but am getting an error:我在 Windows 机器上安装了 npm-run-all 并配置了环境变量(可能不需要也可能不需要),但出现错误:
'npm-run-all' is not recognized as an internal or external command, operable program or batch file “npm-run-all”不是内部或外部命令,也不是可运行的程序或批处理文件
I am trying to build my current project with npm run build
which includes the script where the error is thrown:我正在尝试使用npm run build
构建我当前的项目,其中包含引发错误的脚本:
npm-run-all -p build-css build-webpack
Do I have to do any additional things to make it run?我是否必须执行任何其他操作才能使其运行?
npm-run-all
is in your package.json devDependencies
.确保npm-run-all
在你的 package.json devDependencies
。npm-run-all
is present in your package.json, run npm i
如果您的 package.json 中存在npm-run-all
,请运行npm i
npm i npm-run-all -D
如果不存在安装它,运行: npm i npm-run-all -D
If error is still present, follow these steps:如果错误仍然存在,请按照下列步骤操作:
rm -rf node_modules
删除 node_modules 文件夹:运行rm -rf node_modules
npm i
安装所有依赖:运行npm i
Hope this helps!希望这可以帮助!
您可能只需要先运行以下命令(从包含 package.json 文件的目录中)
npm install
You have a couple of options here, besides installing npm-run-all
as a global package as suggested by @Vaibhav in the comments:除了按照@Vaibhav 在评论中的建议将npm-run-all
安装为全局包之外,您还有几个选择:
1) Create an NPM script 1) 创建NPM 脚本
The package.json
file has a scripts
section which can used to define shortcuts for anything you need to run while you're working on your app. package.json
文件有一个scripts
部分,可用于为您在处理应用程序时需要运行的任何内容定义快捷方式。 There are some pre-defined scripts, like run
or test
than can be executed with simply npm start
/ npm test
or you can define anything you like and then run it with npm run my-script-name
.有一些预定义的脚本,例如run
或test
,可以通过简单的npm start
/ npm test
执行,或者您可以定义任何您喜欢的内容,然后使用npm run my-script-name
运行它。 You could try:你可以试试:
{
"scripts": {
"start": "npm-run-all -p build-css build-webpack"
}
}
Any NPM module referenced here "just works" (ie the path to the executable is resolved under the hood by NPM)此处引用的任何 NPM 模块都“正常工作”(即,可执行文件的路径由 NPM 在后台解析)
In newer versions of NPM (ie >= 5.2 or so), the "NPX" executable is provided.在较新版本的 NPM(即 >= 5.2 左右)中,提供了“NPX”可执行文件。 This has a similar effect to running commands inside an NPM script.这与在 NPM 脚本中运行命令的效果类似。 You would run:你会运行:
npx npm-run-all -p build-css build-webpack
Again, the path would be automatically resolved.同样,路径将自动解析。
If you have an older NPM install, you can also install it separately:如果您安装了较旧的 NPM,也可以单独安装:
npm install -g npx
Please do that like this.请这样做。
npm i npm-run-all -g
And then this issue will be fixed.然后这个问题将被修复。
npm install -g npm-run-all npm install -g npm-run-all
Works for me.为我工作。
Double check if npm-run-all
is in your package.json
devDependencies
.仔细检查npm-run-all
是否在您的package.json
devDependencies
。
I had same problem while using code editor Brackets.我在使用代码编辑器 Brackets 时遇到了同样的问题。
To resolve the error, I did the following steps.为了解决该错误,我执行了以下步骤。
Add nodejs new system variable to your PC under Control Panel -> System -> Advanced System Settings在控制面板 -> 系统 -> 高级系统设置下将 nodejs 新系统变量添加到您的 PC
;C:\Program Files\nodejs\
After that, re-run command:之后,重新运行命令:
npm
I don't know if this would help anyone, but I got this error because I was doing nodemon server.js instead of nodemon server/server.js.我不知道这是否对任何人有帮助,但我收到此错误是因为我正在执行 nodemon server.js 而不是 nodemon server/server.js。 I wasn't in the right folder!我没有在正确的文件夹中!
Did you reopen the terminal after you installed node?安装节点后是否重新打开终端?
If you have installed npm with the current terminal window open.如果您在当前终端窗口打开的情况下安装了 npm。 Your terminal window will not have loaded the latest path settings (with npm location) to find the npm application to run the command.您的终端窗口将不会加载最新的路径设置(带有 npm 位置)来查找 npm 应用程序来运行命令。 In this case try below steps .在这种情况下,请尝试以下步骤。
This worked for me.这对我有用。
npm audit fix --force
Also you can try downgrading your autoprefixer, seems version 10.0.0 doesn't work well with postcss你也可以尝试降级你的自动前缀,似乎 10.0.0 版本不适用于 postcss
npm i autoprefixer@9.8.6
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.