Closed aryamohanan closed 6 days ago
I'm currently looking into this!
Related: https://github.com/getsentry/sentry-javascript/issues/12325
@timfish Thank you for responding promptly. Looking forward to your updates.
As Prisma is CJS, I think this is fixed by https://github.com/DataDog/import-in-the-middle/pull/96 but I need to confirm.
Hello @timfish
I just used the latest version 1.8.1, but the issue still persists. I am now encountering the following error:
Error: 'import-in-the-middle' failed to wrap 'file:///artifacts/packages/collector/test/tracing/database/prisma/node_modules/@prisma/client/default.js' at getSource (/artifacts/packages/core/node_modules/import-in-the-middle/hook.js:304:21) at async load (/artifacts/packages/core/node_modules/import-in-the-middle/hook.js:319:26) at async nextLoad (node:internal/modules/esm/hooks:866:22) at async Hooks.load (node:internal/modules/esm/hooks:449:20) at async MessagePort.handleMessage (node:internal/modules/esm/worker:196:18) { cause: TypeError: emitImportAssertionWarning is not a function at defaultLoad (node:internal/modules/esm/load:119:5) at nextLoad (node:internal/modules/esm/hooks:866:28) at getExports (/artifacts/packages/core/node_modules/import-in-the-middle/lib/get-exports.js:80:27) at processModule (/artifacts/packages/core/node_modules/import-in-the-middle/hook.js:131:29) at getSource (/artifacts/packages/core/node_modules/import-in-the-middle/hook.js:269:31) at load (/artifacts/packages/core/node_modules/import-in-the-middle/hook.js:319:32) at nextLoad (node:internal/modules/esm/hooks:866:28) at Hooks.load (node:internal/modules/esm/hooks:449:26) at MessagePort.handleMessage (node:internal/modules/esm/worker:196:24) at [nodejs.internal.kHybridDispatch] (node:internal/event_target:825:20) } import { PrismaClient } from '@prisma/client'; ^^^^^^^^^^^^ SyntaxError: The requested module '@prisma/client' does not provide an export named 'PrismaClient' at ModuleJob._instantiate (node:internal/modules/esm/module_job:134:21) at async ModuleJob.run (node:internal/modules/esm/module_job:217:5) at async ModuleLoader.import (node:internal/modules/esm/loader:316:24) at async asyncRunEntryPointWithESMLoader (node:internal/modules/run_main:123:5)
A warning is logged to the console but it no longer throws.
@timfish, could you please let me know when the fix is released? Thank you.
I am encountering an issue while using prisma module in my test folder along with the import-in-the-middle. When attempting to import the prisma module from a subdirectory, I receive the following error:
This occurs when I install and use the prisma package in a subdirectory. Notably, the issue only arises with Node.js version 18.19 and above. Versions 18 and below do not exhibit this problem. Additionally, the issue does not occur when the import-in-the-middle hook is not used.
If I add the prismato the root package.json, the error does not occur. However, due to project compliance, I am not allowed to include the the package in the root directory.
Expected Behavior
The prisma package should be successfully imported and executed without errors. When I run the command
node --loader ./hook.mjs packages/a/test/prisma/app.mjs
it should not throw any error.Actual Behavior
The error Cannot find module '.prisma/client/default' is thrown.
Steps to Reproduce the Problem
npm i
.cd packages/a/test/prisma/
npm i
within this directory.cd ../../../../
Execute the following command
node --loader ./hook.mjs packages/a/test/prisma/app.mjs
ornode --import ./register packages/a/test/prisma/app.mjs
both are throwing errors.Specifications