【问题标题】:nodemon not able to start nodejs app with express v4nodemon 无法使用 express v4 启动 nodejs 应用程序
【发布时间】:2016-09-19 12:03:59
【问题描述】:

这个问题必须有一些简单的解决方案。我使用 Webstorm 为 Express js + Node js 创建了一个新项目。然后我使用npm install -g nodemon 安装了 nodemon 并且很好。但是当我尝试使用 nodemon app.js 启动我的应用程序时,它只显示

sany2k8@sany2k8-Aspire-4752:/var/projects/ENStack$ nodemon app.js

[nodemon] 1.9.2

[nodemon]随时重启,输入rs[nodemon]观看:.

[nodemon] 开始 node app.js

[nodemon] 干净退出 - 重启前等待更改

package.json

{
  "name": "ENStack",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "node ./bin/www"
  },
  "dependencies": {
    "body-parser": "~1.13.2",
    "cookie-parser": "~1.3.5",
    "debug": "~2.2.0",
    "express": "~4.13.1",
    "jade": "~1.11.0",
    "morgan": "~1.6.1",
    "serve-favicon": "~2.3.0"
  }
}

编辑:当我尝试使用npm start 时,它显示了一堆错误

sany2k8@sany2k8-Aspire-4752:/var/projects/ENStack$ npm start

ENStack@0.0.0 启动 /var/projects/ENStack 节点./bin/www

端口 3000 已在使用中

【问题讨论】:

  • 我记得很久以前也有同样的问题,它与npm permissions有关。但是您的似乎并非如此,但是您是否在获得适当许可的情况下安装了它?
  • 是的@AbhinavGauniyal
  • 您是否检查过您的进程以确认它没有运行?没有错误消息?
  • 运行node app.js时app.js是否正常工作?
  • 您收到的错误是什么?当您在端口 3000 的另一个进程中运行另一个节点应用程序时,端口 3000 已在使用中发生。

标签: node.js express npm webstorm nodemon


【解决方案1】:

我们需要在 json 文件中添加 startnodemon ./bin/www 并 使用:nodemon app

运行您的项目
{
  "name": "ENStack",
  "version": "0.0.0",
  "private": true,
  "scripts": {
    "start": "nodemon ./bin/www"
  },
  "dependencies": {
    "body-parser": "~1.13.2",
    "cookie-parser": "~1.3.5",
    "debug": "~2.2.0",
    "express": "~4.13.1",
    "jade": "~1.11.0",
    "morgan": "~1.6.1",
    "serve-favicon": "~2.3.0"
  }
}

【讨论】:

    【解决方案2】:

    此外,有时该端口正在使用中。如果上述解决方案不适合您,请尝试更改端口。它可能正在用于其他一些节点实例。

    【讨论】:

      猜你喜欢
      • 2014-12-17
      • 2013-11-14
      • 1970-01-01
      • 1970-01-01
      • 2020-06-11
      • 2015-07-18
      • 2013-08-23
      • 2012-11-10
      • 1970-01-01
      相关资源
      最近更新 更多