Error when creating migration
I recently changed my Typescript project to compile from common js to modules. Since the change I have got this error when running drizzle-kit generate
Reading config file '/Users/user/Desktop/project/api/drizzle.config.ts'
Error: Cannot find module './projects.js'
- /Users/user/Desktop/project/api/node_modules/drizzle-kit/bin.cjs
at Module._resolveFilename (node:internal/modules/cjs/loader:1202:15)
at Module._resolveFilename (/Users/user/Desktop/project/api/node_modules/drizzle-kit/bin.cjs:11284:40)
at Module._load (node:internal/modules/cjs/loader:1027:27)
at Module.require (node:internal/modules/cjs/loader:1290:19)
Any help is appreciated.
3 Replies
No help, however I have a similar problem. I am trying to import type definitions into my schema file and I am getting the same error.
Did you manage to find a solution?
nur sure this will help but maybe "type": "module", in package json
I have that. The other files work but not that one. compiling works, just not generate.
Error: Cannot find module '../services/userService.js'
Require stack:
- /home/andre/Documents/code/censored/src/schema/schema.ts
- /home/andre/Documents/code/censored/node_modules/drizzle-kit/bin.cjs
at Module._resolveFilename (node:internal/modules/cjs/loader:1142:15)
at Module._resolveFilename (/home/andre/Documents/code/censored/node_modules/drizzle-kit/bin.cjs:14249:40)
at Module._load (node:internal/modules/cjs/loader:983:27)
at Module.require (node:internal/modules/cjs/loader:1230:19)
at require (node:internal/modules/helpers:179:18)
at Object.<anonymous> (/home/andre/Documents/code/censored/src/schema/schema.ts:14:8)
at Module._compile (node:internal/modules/cjs/loader:1368:14)
at Module._compile (/home/andre/Documents/code/censored/node_modules/drizzle-kit/bin.cjs:11751:31)
at Module._extensions..js (node:internal/modules/cjs/loader:1426:10)
at Object.newLoader [as .ts] (/home/andre/Documents/code/censored/node_modules/drizzle-kit/bin.cjs:11755:13) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/andre/Documents/code/censored/src/schema/schema.ts',
'/home/andre/Documents/code/censored/node_modules/drizzle-kit/bin.cjs'
]
}
I think I have figured it out. The imports don't work with a .js extension. However, I need .js to run the files.
Is there some way of fixing this that doesn't involve updating dozens of imports each time I migrante?