Skip to content

Cannot find module '.prisma/client/default' #12325

Closed
@P4sca1

Description

@P4sca1

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/node

SDK Version

8.7.0

Framework Version

No response

Link to Sentry event

No response

SDK Setup

// Preloaded using node --import flag. Do not import code from other source files here.
// https://docs.sentry.io/platforms/javascript/guides/node/install/esm/
// @ts-check

import { dirname } from 'node:path'
import { fileURLToPath } from 'node:url'
import * as Sentry from '@sentry/node'
import { nodeProfilingIntegration } from '@sentry/profiling-node'

/**
 * The root directory of the application.
 * @see {@link https://docs.sentry.io/platforms/javascript/guides/node/configuration/integrations/rewriteframes/}
 */
const root = dirname(fileURLToPath(import.meta.url))

const env =
	process.env['SENTRY_ENV'] || process.env['NODE_ENV'] || 'development'
const version = process.env['PACKAGE_VERSION']

Sentry.init({
	dsn: 'redacted',
	release: version ? `api@${version}` : undefined,
	environment: env,
	integrations: [
		nodeProfilingIntegration(),
		Sentry.dedupeIntegration(),
		Sentry.rewriteFramesIntegration({ root }),
		Sentry.prismaIntegration(),
	],
	beforeBreadcrumb: (breadcrumb) => {
		// Filter out writes to apollographql reporting API, because they are not helpful for error tracing
		// and spam breadcrumbs.
		if (
			breadcrumb.type === 'http' &&
			typeof breadcrumb.data?.['url'] === 'string' &&
			breadcrumb.data['url'].includes('api.apollographql.com')
		) {
			return null
		}

		return breadcrumb
	},
	tracesSampleRate: 0.1,
	profilesSampleRate: 0.1,
})

Steps to Reproduce

I migrated my code to Sentry v8 and can no longer start my application. I start my app using node --import ./instrument.js ./dist/main.js. I use pnpm as my package manager.

Expected Result

Prisma v8 should work using ESM, pnpm, and prisma.

Actual Result

Error: Cannot find module '.prisma/client/default'
Require stack:
- /Users/pascal/code/ips-hosting/api/node_modules/.pnpm/import-in-the-middle@1.7.4/node_modules/import-in-the-middle/lib/get-exports.js
- /Users/pascal/code/ips-hosting/api/node_modules/.pnpm/import-in-the-middle@1.7.4/node_modules/import-in-the-middle/hook.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15)
    at Function.resolve (node:internal/modules/helpers:136:19)
    at /Users/pascal/code/ips-hosting/api/node_modules/.pnpm/import-in-the-middle@1.7.4/node_modules/import-in-the-middle/lib/get-exports.js:26:33
    at Array.map (<anonymous>)
    at getFullCjsExports (/Users/pascal/code/ips-hosting/api/node_modules/.pnpm/import-in-the-middle@1.7.4/node_modules/import-in-the-middle/lib/get-exports.js:23:40)
    at getExports (/Users/pascal/code/ips-hosting/api/node_modules/.pnpm/import-in-the-middle@1.7.4/node_modules/import-in-the-middle/lib/get-exports.js:83:12)
    at async processModule (/Users/pascal/code/ips-hosting/api/node_modules/.pnpm/import-in-the-middle@1.7.4/node_modules/import-in-the-middle/hook.js:134:23)
    at async getSource (/Users/pascal/code/ips-hosting/api/node_modules/.pnpm/import-in-the-middle@1.7.4/node_modules/import-in-the-middle/hook.js:269:60)
    at async load (/Users/pascal/code/ips-hosting/api/node_modules/.pnpm/import-in-the-middle@1.7.4/node_modules/import-in-the-middle/hook.js:335:26)
    at async nextLoad (node:internal/modules/esm/hooks:833:22) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/pascal/code/ips-hosting/api/node_modules/.pnpm/import-in-the-middle@1.7.4/node_modules/import-in-the-middle/lib/get-exports.js',
    '/Users/pascal/code/ips-hosting/api/node_modules/.pnpm/import-in-the-middle@1.7.4/node_modules/import-in-the-middle/hook.js'
  ]
}

Metadata

Metadata

Assignees

Type

Projects

Status

No status

Relationships

None yet

Development

No branches or pull requests

Issue actions