所以我的package.json中的npm开始看起来像这样
"start": "REACT_APP_Environment=development react-scripts start",
这对于该项目以前的开发人员来说效果很好,可能是因为他们在MacOS上,而在Windows上运行时,我却不是
> REACT_APP_Environment=development react-scripts start
'REACT_APP_Environment' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! enterprise@0.1.0 start: `REACT_APP_Environment=development react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the enterprise@0.1.0 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:
npm ERR! C:\Users\Omar\AppData\Roaming\npm-cache\_logs\2019-09-22T15_12_59_217Z-debug.log
我可以通过从启动脚本中删除环境变量并通过命令set "REACT_APP_Environment=development" && npm start
运行来解决此问题,但这并不方便,如何在启动脚本中将其全部包含在内并在Windows上正常工作?谢谢
答案 0 :(得分:2)
我建议您检出.env,看来它可以解决您的问题
npmjs.com/package/dotenv