简体   繁体   中英

docker Cannot find module 'Sequelize'

Getting below error after deploying docker image:

Cannot find module 'Sequelize'

Directory structure:

src
views
Dockerfile
package.json

Dockerfile:

FROM node:8
ENV PORT 3000
EXPOSE 3000

RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app

COPY package.json /usr/src/app
RUN npm install

COPY . /usr/src/app

CMD ["npm", "run", "prod"]

Package.json:

{
"name": "api",
"version": "0.0.0",
"private": true,
"main": "src/loader.js",
"scripts": {
  "dev": "nodemon",
  "prod": "node src/loader.js"
},
"dependencies": {
  "sequelize": "^4.38.0",
  "cookie-parser": "~1.4.3",
  "cors": "^2.8.4",
  "debug": "~2.6.9",
  "express": "~4.16.0",
  "express-graphql": "^0.6.12",
  "graphql": "^0.13.2",
  "graphql-relay": "^0.5.5",
  "graphql-sequelize": "^9.0.1",
  "http-errors": "~1.6.2",
  "jade": "^1.11.0",
  "morgan": "~1.9.0",
  "mysql2": "^1.6.1"
},
"devDependencies": {
  "nodemon": "^1.18.3"
}

}

Maybe you need to explicitly add the module in your package.json

$ npm install --save sequelize

If the module is declared, it will be found by the dependent module that is causing you that error.

Hope it helps!

可能是拼写错误,即可以验证您使用的是require('sequelize')而不是require('Sequelize')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM