Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 将节点应用程序添加到aws_Node.js_Amazon Web Services_Express - Fatal编程技术网

Node.js 将节点应用程序添加到aws

Node.js 将节点应用程序添加到aws,node.js,amazon-web-services,express,Node.js,Amazon Web Services,Express,我正在将我的节点应用程序添加到aws,但它不会加载实际页面。我认为我的server.js文件有问题,因为如果我将一个锅炉节点应用程序和ssh加载到aws中并运行它,应用程序就会工作。但是,当我运行我的连接时,连接超时,或者我得到一个错误,如 events.js:183 throw er; // Unhandled 'error' event ^ Error: listen EADDRINUSE :::3000 at Object._errnoException (util.js:9

我正在将我的节点应用程序添加到aws,但它不会加载实际页面。我认为我的server.js文件有问题,因为如果我将一个锅炉节点应用程序和ssh加载到aws中并运行它,应用程序就会工作。但是,当我运行我的连接时,连接超时,或者我得到一个错误,如

events.js:183
  throw er; // Unhandled 'error' event
  ^
Error: listen EADDRINUSE :::3000
   at Object._errnoException (util.js:992:11)
at _exceptionWithHostPort (util.js:1014:20)
at Server.setupListenHandle [as _listen2] (net.js:1355:14)
at listenInCluster (net.js:1396:12)
at Server.listen (net.js:1480:7)
    at Function.listen (/home/ubuntu/memory-box/node_modules/express/lib/application.js:618:24)
at Object.<anonymous> (/home/ubuntu/memory-box/server.js:21:5)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3

第一次尝试运行应用程序时,您使用的端口未关闭,因此当您运行应用程序时,该端口正在使用中。您可以关闭端口,然后重试或更改端口

我建议您使用Nodemon进行实验

Nodemon将监视我们的应用程序,并在我们看到任何文件发生更改时自动重新启动服务器。当应用程序关闭端口本身时

var express = require('express'),
app = express(),
port = process.env.PORT || 3000,
mongoose = require('mongoose'),
Task = require('./api/models/memoryBoxModel'), //created model loading here
bodyParser = require('body-parser');
mongoose.Promise = global.Promise; mongoose.connect('mongodb://username:password@ds125402.mlab.com:25402/memorybox', { useNewUrlParser: true });

app.use('/uploads', express.static('uploads'))
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());


var routes = require('./api/routes/memoryBoxRoutes'); //importing route
routes(app); //register the route


app.listen(port);

app.use(function(req, res) {
// The snippet bellow helps to redirect and respond whenever a wrong 
route is entered on the site.
 res.status(404).send({url: req.originalUrl + ' not found'})
});

console.log('todo list RESTful API server started on: ' + port);