Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/39.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 节点_ENV此时出现意外错误_Javascript_Node.js_Json_Express - Fatal编程技术网

Javascript 节点_ENV此时出现意外错误

Javascript 节点_ENV此时出现意外错误,javascript,node.js,json,express,Javascript,Node.js,Json,Express,我在youtube上关注本教程,因为我试图学习node.js/express 为了能够使用nodemon,我在package.json文件中更改了以下内容 package.json "scripts": { "start": "if [[ $NODE_ENV == 'production' ]]; then node ./bin/www; else nodemon ./bin/www; fi" }, 但是,当我在cmd提示符下运行以下命令时,我得到一个错误 set DEBUG=

我在youtube上关注本教程,因为我试图学习node.js/express

为了能够使用nodemon,我在package.json文件中更改了以下内容

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并重新安装所有内容
我似乎想不出来。

“脚本”:{ “开始”:“节点。/bin/www” }


现在运行nodemon或npm start

我试着在全局范围内安装nodemon,结果成功了

npm安装-g nodemon


并使用
nodemon
启动应用程序

我收到了相同的错误,但我将其更改为:

"scripts": {
   "start": "node ./bin/www",
   "dev": "nodemon ./bin/www"
 },
   

我用“纱线开发”和“npm运行开发”来实现npm。如果你只想运行nodemon,你可以这样做

"start" : "nodemon ./bin/www"

就这些。您已准备就绪

您的shell需要能够解释该语法。这不是安装问题,而是shell语法错误。就像我在Ubuntu上尝试使用
rmdir/S/qwww
,它会失败
"start" : "nodemon ./bin/www"