我的项目在更新我的节点版本后没有执行(更新到这两个v8.9.4和v9.4),可以帮助我一下,下面列出的软件包是否兼容最新的节点版本以及如何解决这个问题。 我的package.json:
{
"name": "v2",
"version": "0.0.0",
"private": true,
"scripts": {
"start": "nodemon -e html,css,js -i node_modules bin/server.js"
},
"dependencies": {
"async": "^1.4.2",
"aws-sdk": "^2.5.1",
"body-parser": "~1.12.4",
"bson": "^0.4.23",
"compression": "^1.5.2",
"connect-mongo": "~0.8.2",
"cookie-parser": "~1.3.5",
"debug": "~2.2.0",
"email-existence": "^0.1.5",
"express": "^4.12.4",
"express-session": "~1.11.3",
"fb": "^1.1.1",
"gm": "^1.18.1",
"html-pdf": "^2.0.1",
"image-size": "^0.5.0",
"jimp": "^0.2.24",
"jsonwebtoken": "^7.0.1",
"mailcomposer": "^3.10.0",
"mailgun": "^0.5.0",
"mailgun-js": "^0.7.10",
"mime": "^1.3.4",
"moment": "^2.13.0",
"mongodb": "^1.4.38",
"mongoskin": "^1.4.13",
"morgan": "~1.5.3",
"multer": "^1.0.3",
"node-schedule": "^1.1.1",
"nodemailer": "v0.7.1",
"paperwork": "^2.1.1",
"paypal-rest-sdk": "^1.6.8",
"qs": "^4.0.0",
"quick-pay": "^1.2.0",
"serve-favicon": "~2.2.1",
"sharp": "^0.15.1",
"swig": "^1.4.2",
"underscore": "^1.8.3"
},
"devDependencies": {
"request": "^2.58.0",
"striptags": "^2.0.2"
}
}
在下面添加了我的server.js,直到v7就可以了。 server.js
var app = require('../app');
var http = require('http');
var fs = require('fs');
var port = normalizePort(process.env.PORT || '3000');
app.set('port', port);
server.listen(port);
server.on('error', onError);
server.on('listening', onListening);
function normalizePort(val) {
var port = parseInt(val, 10);
if (isNaN(port)) {
// named pipe
return val;
}
if (port >= 0) {
// port number
return port;
}
return false;
}
function onError(error) {
if (error.syscall !== 'listen') {
throw error;
}
var bind = typeof port === 'string' ? 'Pipe ' + port : 'Port ' + port;
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
throw error;
}
}
function onListening() {
var addr = server.address();
var bind = typeof addr === 'string' ? 'pipe ' + addr : 'port ' + addr.port;
console.log('Listening on ' + bind);
if (fs.existsSync('/code/resTest/test/index.js')) {
console.log('touching marker');
fs.writeFileSync("/code/resTest/test/marker.js", '');
}
}