简体   繁体   English

对于 REACT_APP_RELEASE 变量,命令“纱线构建”在 Windows 10 上失败

[英]Command 'yarn build' fails on Windows 10 for REACT_APP_RELEASE variable

Inside package.json the build script is something like:package.jsonbuild脚本类似于:

"build": "REACT_APP_RELEASE=$npm_package_version REACT_APP_COMMIT_REF=$COMMIT_REF react-scripts build && echo $COMMIT_REF >> build/version.txt",

When I run the command yarn build I get following error:当我运行命令yarn build以下错误:

'REACT_APP_RELEASE' is not recognized as an internal or external command, operable program or batch file. error Command failed with exit code 1.

What should I do?我该怎么办?

Step 1第1步

Install the cross-env module.安装cross-env模块。

npm install cross-env

or或者

yarn add cross-env

Step 2第2步

Add cross-env before REACT_APP_RELEASE variable in the build script.build脚本中的REACT_APP_RELEASE变量之前添加cross-env If REACT_APP_RELEASE variable is in the middle of your build script you have to always add cross-env just before the REACT_APP_RELEASE variable.如果REACT_APP_RELEASE变量位于构建脚本的中间,则必须始终在REACT_APP_RELEASE变量之前添加cross-env

Full command:完整命令:

"build": "cross-env REACT_APP_RELEASE=$npm_package_version REACT_APP_COMMIT_REF=$COMMIT_REF react-scripts build && echo $COMMIT_REF >> build/version.txt",

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM