[英]node events.js:136 throw er; Unhandled 'error' event
I am getting events.js:136 throw er; 我正在接受events.js:136 throw er; Unhandled 'error' event don't know how and why? 未处理的'错误'事件不知道如何以及为什么? i have reinstalled the nodejs and mongodb as well but throwing same error. 我已经重新安装了nodejs和mongodb但是抛出相同的错误。
package.json 的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 code 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...');
Try to use the following commands to enlarge the number of handlers that actives the watcher (listener of application changes) 尝试使用以下命令来扩大激活观察者的处理程序数量(应用程序的监听器更改)
sudo sysctl fs.inotify.max_user_watches=524288
sudo sysctl -p --system
sudo sysctl fs.inotify.max_user_watches=524288
sudo sysctl -p --system
I have got that root cause.. i have not made any database using mongodb its a connection error.. 我有根本原因..我没有使用mongodb创建任何数据库它的连接错误..
thanks Mark for your time. 感谢马克的时间。
The issue in port 端口问题
app.listen(8080);
try these code 试试这些代码
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.