在克隆了一个包含ReactJS和NodeJS项目的Git仓库之后,安装NodeJS。
我希望在浏览器中看到结果,因此必须在根目录下运行,该目录包含一个 package.json 文件。
npm install
然后执行以下命令:
npm start
第一个命令正常工作,但是第二个命令出现以下错误:
> 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
npm
如何调用外部程序有关。 - Quentincross-env
包。 - Quentin