【发布时间】:2019-11-10 14:24:55
【问题描述】:
我在 youtube 上关注本教程,因为我正在尝试学习 node.js / express。
我在 package.json 文件中更改了以下内容,以便能够使用 nodemon。
package.json
"scripts": {
"start": "if [[ $NODE_ENV == 'production' ]]; then node ./bin/www; else nodemon ./bin/www; fi"
},
但是,当我在 cmd 提示符下运行以下命令时,出现错误。
set DEBUG=myapp:* & npm start
以下错误:
$NODE_ENV was unexpected at this time.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myapp@0.0.0 start: `if [[ $NODE_ENV == 'production' ]]; then node ./bin/www; else nodemon ./bin/www; fi`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the myapp@0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
- 我已经尝试更新所有 npm 模块。 -我试过删除 package-lock.json 并重新安装所有东西。
我好像想不通。
【问题讨论】:
-
您的 shell 需要能够解释该语法。这不是安装问题,而是 shell 语法错误。就像我在 Ubuntu 上尝试使用
rmdir /S /Q www一样,它会失败
标签: javascript node.js json express