Ricardo Almeida
10/14/2020, 12:22 PMinternal/modules/cjs/loader.js:960
throw err;
^
Error: Cannot find module '@prisma/client'
Require stack:
- /app/dist/context.js
- /app/dist/index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
at Function.Module._load (internal/modules/cjs/loader.js:840:27)
at Module.require (internal/modules/cjs/loader.js:1019:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (/app/dist/context.js:4:18)
at Module._compile (internal/modules/cjs/loader.js:1133:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
at Module.load (internal/modules/cjs/loader.js:977:32)
at Function.Module._load (internal/modules/cjs/loader.js:877:14)
at Module.require (internal/modules/cjs/loader.js:1019:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/app/dist/context.js', '/app/dist/index.js' ]
}
Ryan
10/14/2020, 12:25 PMRicardo Almeida
10/14/2020, 12:26 PM"@nexus/schema": "^0.16.0",
Ricardo Almeida
10/14/2020, 12:27 PMyarn dev
runs ok. It occurs only when I build in dockerRyan
10/14/2020, 12:28 PMRyan
10/14/2020, 1:14 PMDockerfile
?Ricardo Almeida
10/14/2020, 1:23 PMFROM node:12.16-alpine
ARG SERVER_PORT=4600
WORKDIR /app
COPY package.json yarn.lock tsconfig.json ./
RUN yarn install
COPY src ./src/
COPY prisma ./prisma/
ENV SERVER_PORT=$SERVER_PORT
RUN yarn prisma generate
RUN yarn run build
# Remove dev dependencies
RUN yarn install --production
EXPOSE $SERVER_PORT
CMD ["node", "dist/index.js"]
Ricardo Almeida
10/14/2020, 1:24 PM"build": "yarn -s clean && yarn -s generate && tsc",
Ryan
10/14/2020, 1:47 PMDockerfile
looks fine.
Hereโs mine that I used to check. https://github.com/ryands17/nexus-authRicardo Almeida
10/14/2020, 2:05 PMDockerfile
works if I comment this RUN yarn install --production
.
I do it to be able to remove devDependencies from production after compiling. For some reason in 2.9.0 is doesn't workRyan
10/14/2020, 2:08 PMRicardo Almeida
10/14/2020, 2:11 PM"devDependencies": {
"@prisma/cli": "2.9.0",
"@prisma/client": "2.9.0",
"@types/node": "^14.11.8",
"ts-node": "^9.0.0",
"ts-node-dev": "^1.0.0-pre.63",
"typescript": "^4.0.3"
}
Ricardo Almeida
10/14/2020, 2:12 PMtypegenAutoConfig: {
contextType: "Context.Context",
sources: [
{
source: ".prisma/client",
alias: "prisma",
},
{
source: require.resolve("./context"),
alias: "Context",
},
],
}
Ryan
10/14/2020, 2:12 PM@prisma/client
should be in dependencies and not devRicardo Almeida
10/14/2020, 2:15 PMRicardo Almeida
10/15/2020, 7:20 AMRyan
10/15/2020, 7:22 AM