Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can we please add commonjs to "exports" in 'package.json'?sometimes" ES Module not supported" #199

Closed
Yancy1028 opened this issue Dec 29, 2021 · 1 comment

Comments

@Yancy1028
Copy link

Yancy1028 commented Dec 29, 2021

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
Copy link
Owner

Duplicate of #189

@sindresorhus sindresorhus marked this as a duplicate of #189 Dec 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants