泊坞窗找不到模块'Sequelize'

时间:2018-08-23 15:53:25

标签: node.js docker npm

部署docker映像后出现以下错误:

  

找不到模块'Sequelize'

目录结构:

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"
}

}

2 个答案:

答案 0 :(得分:0)

也许您需要在package.json中显式添加模块

$ npm install --save sequelize

如果声明了模块,则将由引起您该错误的依赖模块找到它。

希望有帮助!

答案 1 :(得分:0)

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