diff --git a/packages/nextjs/src/config/loaders/wrappingLoader.ts b/packages/nextjs/src/config/loaders/wrappingLoader.ts index 28c8f58b2eb9..53891bb298a9 100644 --- a/packages/nextjs/src/config/loaders/wrappingLoader.ts +++ b/packages/nextjs/src/config/loaders/wrappingLoader.ts @@ -203,7 +203,15 @@ export default function wrappingLoader( } if (sentryConfigFilePath) { - templateCode = `import "${sentryConfigFilePath}";`.concat(templateCode); + let importPath = sentryConfigFilePath; + + // absolute paths do not work with Windows + // https://github.com/getsentry/sentry-javascript/issues/8133 + if (path.isAbsolute(importPath)) { + importPath = path.relative(path.dirname(this.resourcePath), importPath); + } + + templateCode = `import "${importPath.replace(/\\/g, '/')}";\n`.concat(templateCode); } } else if (wrappingTargetKind === 'middleware') { templateCode = middlewareWrapperTemplateCode;