bluwy / publint

Lint packaging errors
https://publint.dev
MIT License
932 stars 19 forks source link

No "exports" main defined #51

Closed xxholly32 closed 1 year ago

xxholly32 commented 1 year ago

Error occurs when using @vite/release-script node version 18; Also, the project is not type:module

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in E:\workspace\element-plus-xx\node_modules.pnpm\@vitejs+release-scripts@1.2.1\node_modules\publint\package.json

bluwy commented 1 year ago

publint is ESM only and the nodejs environment you use should support the "exports" field, and not only "main". Can you show how you're importing publint? If you're using it through @vitejs/release-scripts, it is also an ESM only package, so I'm not sure how you're seeing the issue.

For ESM only packages, make sure you're importing it and not require.

xxholly32 commented 1 year ago

https://github.com/xxholly32/element-plus/commit/cad196297937f28b32b759ac39476aef02534c22

I would like to propose a pr for element-plus by adding @vitejs/release-scripts ;

bluwy commented 1 year ago

Renaming the scripts from .ts to .mts should do the trick. e.g. publish.ts -> publish.mts. tsx is converting to CJS under the hood.

xxholly32 commented 1 year ago

yes. It does solve the problem. ty for your time ❤