节点事件。js:136 er扔;未处理的“错误”事件

时间:2021-07-10 00:09:18

I am getting 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.

我得到的事件。js:136 er扔;未处理的“错误”事件不知道如何和为什么?我也重新安装了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...');

节点事件。js:136 er扔;未处理的“错误”事件

3 个解决方案

#1


2  

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系统。

#2


0  

I have got that root cause.. i have not made any database using mongodb its a connection error..

我有这个根本原因。我没有使用mongodb做任何数据库,这是一个连接错误。

thanks Mark for your time.

谢谢你,马克。

#3


0  

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

#1


2  

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系统。

#2


0  

I have got that root cause.. i have not made any database using mongodb its a connection error..

我有这个根本原因。我没有使用mongodb做任何数据库,这是一个连接错误。

thanks Mark for your time.

谢谢你,马克。

#3


0  

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