I am running node 14.
I have a package that has this in the package.json
"main": "dist/index.js",
"type": "commonjs",
There are no browser or module fields.
It is a typescript project that I compile to a .cjs output.
The problem is that when I start nodemon like this:
nodemon --watch 'src/**/*' -e ts,tsx --exec ts-node ./src/index.ts
I get this error:
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /Users/blah/dist/index.js
The module in question has module, 'mainandbrowserfields but its type ismodule`.
It has index.js and index.cjs files but index.js file is being chosen.
everything is fine when I run the compiled output that which is a .cjs file.
Is there a way to let node know that I want everything to run under commonjs.