Javascript 投掷者;//未处理';错误';事件-节点 描述
我正在尝试运行我的节点应用程序Javascript 投掷者;//未处理';错误';事件-节点 描述,javascript,angularjs,node.js,gulp,nodemon,Javascript,Angularjs,Node.js,Gulp,Nodemon,我正在尝试运行我的节点应用程序 npm run start 我一直在 > api@1.0.0 start /Users/bheng/Sites/BASE/api > nodemon ./bin/index.js -w server [nodemon] 1.11.0 [nodemon] to restart at any time, enter `rs` [nodemon] watching: /Users/bheng/Sites/BASE/api/server/**/* [no
npm run start
我一直在
> api@1.0.0 start /Users/bheng/Sites/BASE/api
> nodemon ./bin/index.js -w server
[nodemon] 1.11.0
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: /Users/bheng/Sites/BASE/api/server/**/*
[nodemon] starting `node ./bin/index.js`
events.js:160
throw er; // Unhandled 'error' event
^
Error: listen EADDRINUSE :::8000
at Object.exports._errnoException (util.js:1018:11)
at exports._exceptionWithHostPort (util.js:1041:20)
at Server._listen2 (net.js:1258:14)
at listen (net.js:1294:10)
at Server.listen (net.js:1390:5)
at EventEmitter.listen (/Users/bheng/Sites/BASE/api/node_modules/express/lib/application.js:618:24)
at Object.<anonymous> (/Users/bheng/Sites/BASE/api/bin/index.js:8:5)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:389:7)
at startup (bootstrap_node.js:149:9)
at bootstrap_node.js:504:3
[nodemon] app crashed - waiting for file changes before starting...
./node_modules/.bin/nodemon
/bin/index.js
server/app.js
如何调试这个呢
错误:侦听EADDRINUSE::8000
您的错误消息刚刚告诉您原因,8000也被其他应用程序使用,请尝试在diff端口上运行它
要获取您可以安全使用的端口列表,请参阅
错误:侦听EADDRINUSE::8000
您的错误消息刚刚告诉您原因,8000也被其他应用程序使用,请尝试在diff端口上运行它
要获得您可以安全使用的端口列表,请参阅,正如Abhijeet和Keith指出的那样,8000端口上正在运行另一个进程 要杀死所有NodeJS进程并随后释放8000端口,以便您可以在应用程序上使用,请使用以下代码:
killall节点
或者像伯迪克那样指向右边:
ps aux | grep node
获取NodeJS进程及其ID的列表
及
kill-9PID
-使用使用8000端口的进程ID更改PID。正如Abhijeet和Keith指出的,8000端口上运行着另一个进程
要杀死所有NodeJS进程并随后释放8000端口,以便您可以在应用程序上使用,请使用以下代码:
killall节点
或者像伯迪克那样指向右边:
ps aux | grep node
获取NodeJS进程及其ID的列表
及
kill-9 PID
-使用使用8000端口的进程ID更改PID
错误:侦听EADDRINUSE::8000
- 找出哪个应用程序正在使用端口8000:
lsof-n | grep LISTEN | grep:8000
- 第一列将指示流程
- 要么终止进程,要么找出需要正常关闭的应用程序
- 找出哪个应用程序正在使用端口8000:
lsof-n | grep LISTEN | grep:8000
- 第一列将指示流程
- 要么终止进程,要么找出需要正常关闭的应用程序
错误:侦听eaddrinue:::8000
端口8000上已运行某些内容…请将端口切换到其他端口。我可以更改为diff端口。我不介意,但如何找到使用该端口的确切应用程序或进程?你们知道吗?Error:listen EADDRINUSE:::8000
端口8000上已经运行了一些东西…请将端口切换到其他端口。我可以更改为diff端口。我不介意,但如何找到使用该端口的确切应用程序或进程?你们知道吗?
{
"name": "api",
"version": "1.0.0",
"description": "",
"main": "bin/index.js",
"scripts": {
"start": "./node_modules/.bin/nodemon ./bin/index.js -w server",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"bluebird": "^3.5.0",
"body-parser": "^1.15.2",
"cors": "^2.8.4",
"express": "^4.14.0",
"helmet": "^3.8.1",
"jwt-decode": "^2.2.0",
"jwt-express": "^1.1.0",
"lodash": "^4.17.4",
"morgan": "^1.7.0",
"pg": "^6.2.4",
"pg-hstore": "^2.3.2",
"request": "^2.81.0",
"request-promise": "^4.2.1",
"sequelize": "^4.1.0"
},
"devDependencies": {
"eslint": "^2.13.1",
"eslint-config-airbnb": "^9.0.1",
"eslint-plugin-import": "^1.10.2",
"eslint-plugin-jsx-a11y": "^1.5.5",
"eslint-plugin-react": "^5.2.2",
"google-translate-api": "^2.3.0",
"nodemon": "^1.11.0"
}
}
#!/usr/bin/env node
'use strict';
var cli = require('../lib/cli');
var nodemon = require('../lib/');
var options = cli.parse(process.argv);
nodemon(options);
var fs = require('fs');
// checks for available update and returns an instance
var defaults = require('lodash.defaults');
var pkg = JSON.parse(fs.readFileSync(__dirname + '/../package.json'));
require('update-notifier')({
pkg: defaults(pkg, { version: '0.0.0' }),
}).notify();
// This will be our application entry. We'll setup our server here.
const http = require('http');
const app = require('../server/app.js'); // The express app we just created
const port = parseInt(process.env.PORT, 10) || 8000;
app.set('port', port);
// const server = http.createServer(app);
app.listen(port, () => {
console.log(`The server is running at localhost:${port}`);
});
const helmet = require('helmet');
const cors = require('cors');
const express = require('express');
const jwt = require('jwt-express');
const logger = require('morgan');
const bodyParser = require('body-parser');
const Bluebird = require('bluebird');
const lodash = require('lodash');
Promise = Bluebird;
_ = lodash;
const app = express();
app.use(helmet());
app.use(cors());
app.options('*', cors());
app.use(logger('dev'));
app.use(jwt.init('**********', {
cookies: false
}));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
require('./routes')(app);
app.get('*', (req, res) => res.status(200).send({
message: 'Welcome to the beginning of nothingness.',
}));
app.use(function(err, req, res, next) {
if (err.name == 'JWTExpressError') {
res.status(401).send('401', {
error: {
message: err.message
}
});
} else {
next(err);
}
});
module.exports = app;