-
Notifications
You must be signed in to change notification settings - Fork 52
Description
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:
node:internal/process/esm_loader:40
internalBinding('errors').triggerUncaughtException(
^
Error: Cannot find module '.prisma/client/default'
Require stack:
/prismabug/node_modules/import-in-the-middle/lib/get-exports.js
/prismabug/node_modules/import-in-the-middle/hook.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1134:15)
at Function.resolve (node:internal/modules/helpers:188:19)
at /prismabug/node_modules/import-in-the-middle/lib/get-exports.js:26:33)
at Array.map ()
at getFullCjsExports (/prismabug/node_modules/import-in-the-middle/lib/get-exports.js:23:40)
at getExports (/prismabug/node_modules/import-in-the-middle/lib/get-exports.js:76:12)
at async processModule (/prismabug/node_modules/import-in-the-middle/hook.js:131:23)
at async getSource (/prismabug/node_modules/import-in-the-middle/hook.js:249:23)
at async load (/prismabug/node_modules/import-in-the-middle/hook.js:280:26)
at async nextLoad (node:internal/modules/esm/hooks:864:22) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/prismabug/node_modules/import-in-the-middle/lib/get-exports.js',
'/prismabug/node_modules/import-in-the-middle/hook.js'
]
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
- Unzip prismabug.zip.
- Run
npm i. - Navigate to the Prisma test directory:
cd packages/a/test/prisma/ - Run
npm iwithin this directory. - Return to the root directory:
cd ../../../../ - Execute the following command
node --loader ./hook.mjs packages/a/test/prisma/app.mjs
or
node --import ./register packages/a/test/prisma/app.mjs
both are throwing errors.
Specifications
- Version: 1.8.0
- Platform: arm64
- Subsystem: Node 18.19