You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Check if migrations are needed. Useful for bash scripts.
...
TypeError [ERR_IMPORT_ASSERTION_TYPE_MISSING]: Module "file:///xxx/src/migrations/.snapshot.json" needs an import assertion of type "json"
at new NodeError (node:internal/errors:405:5)
at validateAssertions (node:internal/modules/esm/assert:95:15)
at defaultLoad (node:internal/modules/esm/load:91:3)
at nextLoad (node:internal/modules/esm/loader:163:28)
at xxx\node_modules\ts-node\src\esm.ts:255:45
at async addShortCircuitFlag (xxx\node_modules\ts-node\src\esm.ts:409:15)
at async nextLoad (node:internal/modules/esm/loader:163:22)
at async ESMLoader.load (node:internal/modules/esm/loader:603:20)
at async ESMLoader.moduleProvider (node:internal/modules/esm/loader:457:11)
at async link (node:internal/modules/esm/module_job:68:21) {
code: 'ERR_IMPORT_ASSERTION_TYPE_MISSING'
}
Describe the bug
Affects only 6.2.2, both Windows and Linux
Affects only commands and only related to snapshots (not programmatic usage)
It looks like that in 7e8409b the support to
require
json files have been removed together with a jest workaround.Partially reverting commit fixes the issue
Context
The
dynamicImport
method by default uses config'smikro-orm/packages/core/src/utils/Configuration.ts
Line 154 in ff3148b
which produces the error.
Node's dynamic
import()
for json files should be used along withImport attributes in node >= 18.20
Import assertions in node < 18.20
Another thing is that the json file is imported in the
default
namespace.As as result, such fix is possible:
Reproduction
Prepare project as in docs > Creating a new project
Execute
npx mikro-orm-esm migration:check
See output
What driver are you using?
@mikro-orm/sqlite
MikroORM version
6.2.2
Node.js version
18.18.2
Operating system
Windows
Validations
The text was updated successfully, but these errors were encountered: