gpt4 book ai didi

node.js - nodemon 无法使用express v4 启动nodejs 应用程序

转载 作者:太空宇宙 更新时间:2023-11-03 23:31:38 28 4
gpt4 key购买 nike

必须有一些简单的解决方案来解决这个问题。我使用 Webstorm for 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] to restart at any time, enter rs [nodemon] watching: .

[nodemon] starting node app.js

[nodemon] clean exit - waiting for changes before restart

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 start /var/projects/ENStack node ./bin/www

端口 3000 已被使用

最佳答案

我们需要在 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"
}
}

关于node.js - nodemon 无法使用express v4 启动nodejs 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37376908/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com