CommonJS/Module Errors Feel Random?
Hey! I have two projects with an identical configuration. For some reason, one project will run while the other one will fail due to an ES Module error.
package.json and tsconfig.json of project that works:
package.json and tsconfig.json of project that does not work:
The first project is basically the prisma-express.js example from their github repo.
The second project is just me trying to learn how to make a CLI app.
6 Replies
The error:
I am using ES imports in both projects. Is there something I am fundamentally missing/misunderstanding?
Here is index.ts of the app that does not work:
(I understand that I can likely solve the issue by following the helpful chain of error messages but that would land me in a config that looks quite different. I want to understand why I can't use the same config here!)
My guess would be one of the dependencies of the project that is failing does not support ESM, and uses
require
internallyAh, is there a way to work around that?
Might have something to do with the message in chalk's readme https://github.com/chalk/chalk#install
GitHub
GitHub - chalk/chalk: 🖍 Terminal string styling done right
🖍 Terminal string styling done right. Contribute to chalk/chalk development by creating an account on GitHub.
I see!! I will look into that, thanks for the pointers.