I had a default NestJS project with MikroORM 4, build with WebPack. The project has been created with:
nest new <project>
WebPack was activated when I added a library to the project - it's the default behavior of NestJS. Then I migrated my project into MikroORM from 4.5 to 5.1 and now I have this error during start:
webpack 5.71.0 compiled successfully in 1338 ms
Type-checking in progress...
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './typings' is not defined by "exports" in D:\a\_NEST8_MIKRO5\nest-mikro-test\node_modules\@mikro-orm\core\package.json
at throwExportsNotFound (internal/modules/esm/resolve.js:285:9)
at packageExportsResolve (internal/modules/esm/resolve.js:508:3)
at resolveExports (internal/modules/cjs/loader.js:450:36)
at Function.Module._findPath (internal/modules/cjs/loader.js:490:31)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:888:27)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Module.require (internal/modules/cjs/loader.js:974:19)
at require (internal/modules/cjs/helpers.js:92:18)
at Object.@mikro-orm/core/typings (D:\a\_NEST8_MIKRO5\nest-mikro-test\dist\main.js:967:18)
at __webpack_require__ (D:\a\_NEST8_MIKRO5\nest-mikro-test\dist\main.js:1051:42)
No errors found.
WebPack was NOT added manually, it was provided by NestJS-CLI if you configure it in nest-cli.json:
{
"$schema": "https://json.schemastore.org/nest-cli",
"collection": "@nestjs/schematics",
"sourceRoot": "src",
"compilerOptions": {
"webpack": true <<<<<<<<<<<<<<< WebPack enabled here
}
}
Project can be built successfully. This error comes during the startup. The problem is related to WebPack. If it's disabled (in nest-cli.json) then it can run properly.
An option would be customizing somehow WebPack build but I don't know how to customize WebPack configured by NestJS-CLI (if it's possible would keep NestJS-CLI configured WebPack). Is it possible to add custom WebPack config to NestJS-CLI?
You can download the project from here: https://github.com/tferi99/nest-mikro-test
You should not use deep imports for anything from MikroORM packages. If you need some symbol that is not exported, feel free to send a PR adding it to public exports.
Checking your reproduction, I found this place, where you import from
@mikro-orm/core/typings
instead of just@mikro-orm/core
. The symbol is definitely exportedEntityData
from the root of the package.https://github.com/tferi99/nest-mikro-test/blob/main/src/person/model/person.entity.ts#L2