恶魔“=10=”

Nodemon index.js

我是 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...');

这是 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"
  }
}

我需要做什么才能让 nodemon 找到 index.js 模块?

谢谢

如果您没有 post 任何代码供我们调试,除非我们观看视频(一个小时长),否则我们几乎不可能做任何事情,哈哈。但是通过查看错误,您忘记输入 module.exports = "whatever is suppose to go here in index.js"。或者你忘了在你的服务器上要求它。js/app.js 文件

问题是您的主文件名为 app.js,但在 package.json 文件中您的主文件是 index.js。您需要更改它,以便 nodemon 知道要查找的文件:

"main": "app.js",