当遇到问题是:
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
以下为处理结果!!!===-===
最近由于项目需要,尝试了解一下前端,刚开始想的挺简单的,但是当真实做的时候,完全不是那么回事儿。各种坑啊!
现在发现前端也是挺卷的。当我把代码clone到本机,想在本机上调试clone下来那哥们的代码,也按照文档说明:yarn install了module packages,也运行了:yarn build,前两步挺顺利的。可是当我要运行yarn run dev的时候,诶,诶,下面的这个错误跑出来了。
C:\projectlab> yarn run dev
yarn run v1.22.17
$ NODE_ENV=development & nodemon --watch src app.ts
'NODE_ENV' is not recognized as an internal or external command,
operable program or batch file.
'nodemon' is not recognized as an internal or external command,
operable program or batch file.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Google了一把,原来那哥们是在Linux上开发的,当然各种命令和调试配置文件也是根据Linux环境来写的,原因找到了,怎么解决这个问题呢?
简单,两步搞定!
第一步:安装cross-env
C:\projectlab> yarn add -D cross-env
第二步:添加cross-env到package.json配置文件的script部分命令value内容的最前面,如下所示:
{
...
"scripts": {
"dev": "cross-env NODE_ENV=development & nodemon --watch src app.ts",
"build": "tsc",
"start": "cross-env node index.js",
...
}
...
}