【问题标题】:Unable to start the server无法启动服务器
【发布时间】:2019-07-20 12:41:20
【问题描述】:

每当本地文件发生更改时,我都会尝试使用 nodemon 自动启动服务器,但出现以下错误。


(点击图片放大)

package.json

{
    "name": "myapp", 
    "version": "0.0.0", 
    "private": true, 
    "scripts": {
        "start": "if [[ $NODE_ENV == 'production' ]]; then node ./bin/www; else nodemon ./bin/www; fi"
    }, 
    "dependencies": {
        "cookie-parser": "~1.4.3", 
        "debug": "~2.6.9", 
        "express": "~4.16.0", 
        "http-errors": "~1.6.2", 
        "morgan": "~1.9.0", 
        "pug": "^2.0.3"
    }, 
    "devDependencies": {
        "nodemon": "^1.18.10"
    }
}

【问题讨论】:

  • 请在问题中直接显示错误,无需点击链接,最好是文本而不是图像。

标签: node.js nodemon


【解决方案1】:

看起来启动脚本使用 Bash 脚本语法,但屏幕截图是 Windows 命令终端。该错误是因为 Windows 不理解 Bash 语法。

要立即让您运行,您只需将启动脚本更改为 nodemon ./bin/www。然后,您需要找出正确的语法,或者为生产启动脚本添加另一个脚本,例如生产中的"start-prod": "node ./bin/www"' and runnpm run start-prod`。

【讨论】:

    猜你喜欢
    • 2019-03-28
    • 2011-08-05
    • 2013-12-08
    • 2015-08-15
    • 2021-07-08
    • 2013-06-05
    • 1970-01-01
    • 2013-07-16
    • 2014-05-18
    相关资源
    最近更新 更多