无用&节点新手。我可以在本地运行示例代码,而不会出现任何问题。但是,当我在AWS中部署相同的组件并测试该函数时,总是返回“模块初始化错误:错误”
db.js
------------
'use strict'
//import Sequelize from 'sequelize';
const Sequelize = require('sequelize');
//var db_mode = process.env.NODE_ENV || 'production';
var db_mode = 'development'
//var db_mode = 'production'
let env = require('./env.json')[db_mode];
var db = {};
console.log(env); //Am able to see the values in cloud watch
const database = new Sequelize(env.database, env.username, env.password, {
host: env.host,
port: env.port,
logging: false, Disable the logging. It is consuming the time on lambda function.
dialect: env.dialect,
define: {
timestamps: false,
freezeTableName: true //prevent sequelize from pluralizing table names
},
operatorsAliases: false,
pool: {
max: 5,
min: 0,
acquire: 20000,
idle: 10000
}
});
database.sync()
.then(()=>{
console.log("connection established successfully")
})
.catch((err)=>{
console.log("connection failed")
console.log(err)
})
module.exports = db;
/*module.exports = {
'Sequelize': Sequelize,
'sequelize': sequelize
};*/
我能够看到导入为node_module的续集。从昨天起,我一直无法找出问题的原因,导致我转向你们,以帮助我了解问题所在。