Chr*_*ris 2 mongodb node.js express nodemon
我是nodemon的新手.在12:01 https://www.youtube.com/watch?v=eB9Fq9I5ocs上关注此视频的步骤后
,尝试使用nodemon运行我的应用时出现以下错误:
这是APP.JS档案:
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var mongoose = require('mongoose');
// Connect to Mongoose
mongoose.connect('mongodb://localhost/ChatbotService')
var db = mongoose.connection;
app.get('/', function(req, res){
res.send('Hola4');
});
app.listen(8601);
console.log('Running on port 8601...');
Run Code Online (Sandbox Code Playgroud)
这里是PACKAGE.JSON文件:
{
"name": "chatbot",
"version": "1.0.0",
"description": "chatbot app",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"express": "*",
"body-parser": "*",
"mongoose": "*"
},
"author": "Chris",
"license": "ISC",
"devDependencies": {
"nodemon": "^1.11.0"
}
}
Run Code Online (Sandbox Code Playgroud)
我需要做什么才能让nodemon找到index.js模块?
谢谢
小智 8
问题是您的主文件名为app.js,但在package.json文件中,您的主文件是index.js.您需要更改它,因此nodemon知道要查找的文件:
"main": "app.js",
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3231 次 |
最近记录: |