getsentry/sentry-javascript

Module not found: Can't resolve 'opentelemetry-instrumentation-fetch-node'

JordoTaylor opened this issue · 3 comments

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nextjs

SDK Version

8.10.0

Framework Version

No response

Link to Sentry event

No response

SDK Setup


Sentry.init({
  dsn: 'https://a761521ac9c499f584fd8ff9b38247ec@o4507461801082880.ingest.us.sentry.io/4507461901090816',

  // Adjust this value in production, or use tracesSampler for greater control
  tracesSampleRate: 1,

  // Setting this option to true will print useful information to the console while you're setting up Sentry.
  debug: false,

  replaysOnErrorSampleRate: 1.0,

  // This sets the sample rate to be 10%. You may want this to be 100% while
  // in development and sample at a lower rate in production
  replaysSessionSampleRate: 0.1,

  // You can remove this option if you're not planning to use the Sentry Session Replay feature:
  integrations: [
    Sentry.replayIntegration({
      // Additional Replay configuration goes in here, for example:
      maskAllText: true,
      blockAllMedia: true,
    }),
  ],
});

Steps to Reproduce

  1. create a brand new next app using boilerplate npx create-next-app
  2. accept all defaults
  3. install sentry using wizard npx @sentry/wizard@latest -i nextjs
  4. accept all defaults
  5. npm run dev

Expected Result

Expecting to successfully run server and see my app

Actual Result

❯ npm run dev

> test_sentry@0.1.0 dev
> next dev

  ▲ Next.js 14.2.4
  - Local:        http://localhost:3000
  - Experiments (use with caution):
    · instrumentationHook

 ✓ Starting...
 ○ Compiling /instrumentation ...
 ⨯ ./node_modules/@sentry/node/cjs/integrations/node-fetch.js:22:1
Module not found: Can't resolve 'opentelemetry-instrumentation-fetch-node'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./node_modules/@sentry/node/cjs/index.js
./node_modules/@sentry/nextjs/cjs/index.server.js
./sentry.server.config.ts
./instrumentation.ts
Error: An error occurred while loading instrumentation hook: Cannot find module '/Users/jordantaylor/Dev/REACT/test_sentry/.next/server/instrumentation'
Require stack:
- /Users/jordantaylor/Dev/REACT/test_sentry/node_modules/next/dist/server/dev/next-dev-server.js
- /Users/jordantaylor/Dev/REACT/test_sentry/node_modules/next/dist/server/next.js
- /Users/jordantaylor/Dev/REACT/test_sentry/node_modules/next/dist/server/lib/start-server.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1142:15)
    at /Users/jordantaylor/Dev/REACT/test_sentry/node_modules/next/dist/server/require-hook.js:55:36
    at Module._load (node:internal/modules/cjs/loader:983:27)
    at Module.require (node:internal/modules/cjs/loader:1230:19)
    at mod.require (/Users/jordantaylor/Dev/REACT/test_sentry/node_modules/next/dist/server/require-hook.js:65:28)
    at require (node:internal/modules/helpers:179:18)
    at DevServer.runInstrumentationHookIfAvailable (/Users/jordantaylor/Dev/REACT/test_sentry/node_modules/next/dist/server/dev/next-dev-server.js:436:51)
    at async Span.traceAsyncFn (/Users/jordantaylor/Dev/REACT/test_sentry/node_modules/next/dist/trace/trace.js:154:20)
    at async DevServer.prepareImpl (/Users/jordantaylor/Dev/REACT/test_sentry/node_modules/next/dist/server/dev/next-dev-server.js:214:9)
    at async NextServer.prepare (/Users/jordantaylor/Dev/REACT/test_sentry/node_modules/next/dist/server/next.js:161:13)
    at async initializeImpl (/Users/jordantaylor/Dev/REACT/test_sentry/node_modules/next/dist/server/lib/render-server.js:98:5)
    at async initialize (/Users/jordantaylor/Dev/REACT/test_sentry/node_modules/next/dist/server/lib/router-server.js:423:22)
    at async Server.<anonymous> (/Users/jordantaylor/Dev/REACT/test_sentry/node_modules/next/dist/server/lib/start-server.js:249:36) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/jordantaylor/Dev/REACT/test_sentry/node_modules/next/dist/server/dev/next-dev-server.js',
    '/Users/jordantaylor/Dev/REACT/test_sentry/node_modules/next/dist/server/next.js',
    '/Users/jordantaylor/Dev/REACT/test_sentry/node_modules/next/dist/server/lib/start-server.js'
  ]
}
lforst commented

Hi, would you mind sharing a small reproduction example? Thanks!

steps to reproduce is included in the description....sorry the formatting is a bit off.

Steps to Reproduce

  1. create a brand new next app using boilerplate npx create-next-app
  2. accept all defaults
  3. install sentry using wizard npx @sentry/wizard@latest -i nextjs
  4. accept all defaults
  5. npm run dev

This was due to a local error regarding some npm cache issue. Please disregard