【发布时间】:2020-06-01 13:04:48
【问题描述】:
使用 ReactJS 和 NodeJS 项目和 install NodeJS 克隆 Git 存储库后
想在浏览器中查看结果,因此必须在包含 package.json 的根文件夹中运行
npm 安装
之后
npm 开始
第一个命令运行良好,但第二个出现以下错误
> HOST=0.0.0.0 PORT=8000 ./node_modules/.bin/react-scripts start
'HOST' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ...: `HOST=0.0.0.0 PORT=8000 ./node_modules/.bin/react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ... start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
package.json 有以下内容
"scripts": {
"start": "HOST=0.0.0.0 PORT=8000 ./node_modules/.bin/react-scripts start",
使用 Git Bash、CMD 和 PowerShell 进行测试,并不断收到相同的错误,如下图所示
Git Bash
【问题讨论】:
-
我希望它在 cmd 和 powershell 上失败,但这应该适用于 bash AFAIK
-
@Quentin 是的,我也认为它会起作用,但它没有......
-
@Quentin 刚刚添加了图片来证明我刚才所说的。
-
一定与
npm的炮击方式有关 -
找到一个重复项。使用
cross-env包。