egg-sequelize error:nodejs.SequelizeConnectionError: Class constructor LRUCache cannot be invoked without 'new'
What happens?
Now, i am using eggjs to develop a system and the program running in the local environment is okay. but when i set up my program in the server, the problem informed me that: 我在使用eggjs作为基础框架进行开发相关的系统,现在第一个项目版本好了之后,在本地测试没有问题,但是当程序通过docker打包到线上服务器之后,项目出现了下面的错误
error: 8 ERROR 33 nodejs.SequelizeConnectionError: Class constructor LRUCache cannot be invoked without 'new’ at Promise.tap.then.catch.err (/usr/src/BDMS/bdmsback/node_modules/sequelize/lib/dialects/mysql/connection-manager.js:133:19) at tryCatcher (/usr/src/BDMS/bdmsback/node_modules/bluebird/js/release/util.js:16:23) at Promise._settlePromiseFromHandler (/usr/src/BDMS/bdmsback/node_modules/bluebird/js/release/promise.js:517:31) at Promise._settlePromise (/usr/src/BDMS/bdmsback/node_modules/bluebird/js/release/promise.js:574:18) at Promise._settlePromise0 (/usr/src/BDMS/bdmsback/node_modules/bluebird/js/release/promise.js:619:10) at Promise._settlePromises (/usr/src/BDMS/bdmsback/node_modules/bluebird/js/release/promise.js:695:18) at _drainQueueStep (/usr/src/BDMS/bdmsback/node_modules/bluebird/js/release/async.js:138:12) at _drainQueue (/usr/src/BDMS/bdmsback/node_modules/bluebird/js/release/async.js:131:9) at Async._drainQueues (/usr/src/BDMS/bdmsback/node_modules/bluebird/js/release/async.js:147:5) at Immediate.Async.drainQueues [as _onImmediate] (/usr/src/BDMS/bdmsback/node_modules/bluebird/js/release/async.js:17:14) at runCallback (timers.js:705:18) at tryOnImmediate (timers.js:676:5) at processImmediate (timers.js:658:5) name: "SequelizeConnectionError" parent: {} original: {} pid: 33
I find a similar solution in the github https://github.com/sequelize/sequelize/issues/7840. The advice is modify the .babelrc. Actually, I dont have the file in my project, though i used babel package. i try to add the file .babelrc and the advice appeared in the discussion. but it didnt work at all. 我在github 的一个issue里面发现了类似的问题https://github.com/sequelize/sequelize/issues/7840, 里面说这是babel编译es6和es5之间出现的问题。 然后按照建议的方式对于一些文件进行修改,但是并没有解决这个问题
Context
- Node Version:v10.16.3
- Egg Version:^2.15.1
- Plugin Name:egg sequelize
- Plugin Version:^5.2.0
- Platform:centOS
I fixed the problem by edit the Dockerfile as RUN npm i.
Not the RUN npm i --registry=https://registry.npm.taobao.org,
The problem is caused by the npm package problem provided by taobao.com, running in the Docker, use the official npm package is okay.