Next.js Discord

Discord Forum

Docker with Sentry & NextJS

Unanswered
British Shorthair posted this in #help-forum
Open in Discord
British ShorthairOP
Has anyone had any experience setting up docker with NextJS alongside Sentry.io ?

Currently I am getting this error;
client  | 
client  | > client@0.1.0 dev
client  | > next dev
client  | 
client  | node:internal/modules/cjs/loader:1149
client  |   const err = new Error(message);
client  |               ^
client  | 
client  | Error: Cannot find module '@sentry/nextjs'
client  | Require stack:
client  | - /app/next.config.js
client  |     at Module._resolveFilename (node:internal/modules/cjs/loader:1149:15)
client  |     at /app/node_modules/next/dist/server/require-hook.js:54:36
client  |     at Module._load (node:internal/modules/cjs/loader:990:27)
client  |     at Module.require (node:internal/modules/cjs/loader:1237:19)
client  |     at mod.require (/app/node_modules/next/dist/server/require-hook.js:64:28)
client  |     at require (node:internal/modules/helpers:176:18)
client  |     at Object.<anonymous> (/app/next.config.js:3:30)
client  |     at Module._compile (node:internal/modules/cjs/loader:1378:14)
client  |     at Module._extensions..js (node:internal/modules/cjs/loader:1437:10)
client  |     at Module.load (node:internal/modules/cjs/loader:1212:32) {
client  |   code: 'MODULE_NOT_FOUND',
client  |   requireStack: [ '/app/next.config.js' ]
client  | }
client  | 
client  | Node.js v21.6.1


My next.config.js file is attached as an image alongside my docker file and other pieces of information that I believe related. If there is any further info I can provide pleased let me know and I'd be happy to do so.

2 Replies

Vizsla
Just curious why are you having to install @sentry/nextjs separatley vs including the package in the package.json that's copied into your /app NextJS directory? That way when you run the step RUN npm ci the sentry package gets installed there as well?

I'm assumming it might be a scoping issue with the sentry package being npm install'd in a wrong location. Just my 2c
British ShorthairOP
@Vizsla That was actually a residual test that didn’t really have any effect on the issue, broke before, tried it, and didn’t work after.

Any idea why it would be scoped to a different location if that is your guess?

Sentry/nextjs is also in my package.json for dev and regular deps