Can we please add commonjs to "exports" in 'package.json'?sometimes" ES Module not supported"
Yancy1028 opened this issue · 1 comments
Yancy1028 commented
question
my project use "ts-node",
now, when i import 'ora' ,it tell me "ES Module not supported",
so,i add type:module
to package
and change module:ESNEXT
to tsconfig.json
,then run node --loader ts-node/esm --experimental-specifier-resolution=node src\*.ts
, it's work ok !
but when i convert code to "cjs",and run it with node, it tell me "ES Module not supported", i don't think so it.
why not add export like this?
the code from ava's 'package.json'
"exports": {
".": {
"import": "./entrypoints/main.mjs", // this is ES Module,when my project is ESModule, it's auto import
"require": "./entrypoints/main.cjs" // this is Commonjs , when my project is Commonjs, it's auto import
},
},
"type": "module",
another way
ora@5.x is commonjs
npm i -S ora@5
sindresorhus commented
Duplicate of #189