Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

发布命令报错,提示 'NODE_ENV' 不是内部或外部命令,也不是可运行的程序 #21

Closed
limars874 opened this issue May 3, 2017 · 5 comments

Comments

@limars874
Copy link

limars874 commented May 3, 2017

我这边安装成功之后,npm run dev没有任何问题。但在输入发布命令时报错,不论是npm run build:sit-preview还是npm run build:prod,都提示同一个错误:

'NODE_ENV' 不是内部或外部命令,也不是可运行的程序。

想问问这个是要需要在那里设置一下这个NODE_ENV吗?

平台是windows,node安装在c盘根目录,版本7.9。
注:windows下面,需要把.eslintrc.js下面的

'linebreak-style': 'error',

修改为

'linebreak-style': ['error','windows'],

否则run dev也会报错,会提示一堆如" Expected linebreaks to be 'LF' but found 'CRLF'"之类的错误。

@wyudong
Copy link
Contributor

wyudong commented May 3, 2017

try: http://stackoverflow.com/questions/9249830/how-can-i-set-node-env-production-in-windows

@limars874
Copy link
Author

嗯,我刚搜到这篇,解决了,还说来自问自答.

win下面修改package.json,把里面相应的改掉就行。

"build:prod": "set NODE_ENV=production && node build/build.js",
 "build:sit": "set NODE_ENV=sit && node build/build.js",
 "build:sit-preview": "set NODE_ENV=sit && npm_config_preview=true && npm_config_report=true && node build/build.js",

@limars874
Copy link
Author

补充一下,后来莫名其妙run dev又不行了,于是安装了一个cross-env,把package的dev改成如下:

"dev": "cross-env NODE_ENV=development node build/dev-server.js",

就可以了。理论上下面的也可以这样加cross-env前缀。

@tyhyly
Copy link

tyhyly commented May 5, 2017

windows系统下尽量用cross-env,上面set那种有时候还是会报错~~
npm install cross-env(该插件作用是windows环境下可执行linux命令)

@xiang-fish
Copy link

本地build ok,服务器上build报错“sh: cross-env: 未找到命令”

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants