我正在接受events.js:136 throw er;未处理的'错误'事件不知道如何以及为什么? 我已经重新安装了nodejs和mongodb,但是抛出了相同的错误。
的package.json
{
"name": "bookstore",
"version": "1.0.0",
"description": "simple bookstore app",
"main": "app.js",
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"express": "*",
"body-parser": "*",
"mongoose": "*"
},
"author": "AveesP",
"license": "ISC"
}
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/bookstore');
var db = mongoose.connection;
app.get('/', function(req, res) {
res.send('Hello world!');
});
app.listen(3000);
console.log('Running on port 3000...');
答案 0 :(得分:5)
尝试使用以下命令扩大激活观察者的处理程序数量(应用程序监听器更改)
sudo sysctl fs.inotify.max_user_watches=524288
sudo sysctl -p --system
答案 1 :(得分:0)
我有根本原因..我没有使用mongodb建立任何数据库连接错误..
感谢马克的时间。
答案 2 :(得分:0)
端口问题
app.listen(8080);
试试这些代码
var http = require('http');
//create a server object:
http.createServer(function (req, res) {
res.write('Hello World!'); //write a response to the client
res.end(); //end the response
}).listen(8080); //the server object listens on port 8080