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

Getting: "Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined ...." error #60

Closed
ieazie opened this issue Feb 6, 2022 · 5 comments · Fixed by #61
Closed

Comments

@ieazie
Copy link

ieazie commented Feb 6, 2022

This might be a problem with my setup, however, i keep getting the below error:

internal/process/esm_loader.js:74
internalBinding('errors').triggerUncaughtException(

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /Users/john.doe/Documents/Projects/cli/node_modules/template-file/package.json imported from /Users/john.doe/Documents/Projects/cli/lib/config-generator.js

Please could you help point me in the right direction on resolving this?

@ieazie ieazie closed this as completed Feb 8, 2022
@techfort
Copy link

techfort commented Feb 9, 2022

hey @ieazie how come you closed the issue? i'm getting the same error

@blakek
Copy link
Contributor

blakek commented Feb 9, 2022

We haven't seen this before, but after reading I think I see a way we could test something.

Could one of you remove the exports object from node_modules/template-file/package.json in your project and let me know if it runs?

// Before
"main": "dist/index.js",
"exports": {
  "require": "./dist/index.js"
},
"description": "🔀 Replace {{ variables }} in all your files",

// After
"main": "dist/index.js",
"description": "🔀 Replace {{ variables }} in all your files",

Also, are you using any tooling to transpile to an ES5 target or Node.js CommonJS? Just asking because it seems some build tool sees the exports but doesn't find what it's looking for (e.g. exports.import).

@blakek
Copy link
Contributor

blakek commented Feb 9, 2022

Also, if you have a minimal example, that'd be perfect. It'd help us get this solved a bit sooner.

@blakek blakek reopened this Feb 9, 2022
@ieazie
Copy link
Author

ieazie commented Feb 9, 2022

We haven't seen this before, but after reading I think I see a way we could test something.

Could one of you remove the exports object from node_modules/template-file/package.json in your project and let me know if it runs?

// Before
"main": "dist/index.js",
"exports": {
  "require": "./dist/index.js"
},
"description": "🔀 Replace {{ variables }} in all your files",

// After
"main": "dist/index.js",
"description": "🔀 Replace {{ variables }} in all your files",

Also, are you using any tooling to transpile to an ES5 target or Node.js CommonJS? Just asking because it seems some build tool sees the exports but doesn't find what it's looking for (e.g. exports.import).

I was able to resolve it as below:

// Before
"main": "dist/index.js",
"exports": {
  "require": "./dist/index.js"
},
"description": "🔀 Replace {{ variables }} in all your files",
// After
"main": "dist/index.js",
"exports": {
  ".": "./dist/index.js"
},
"description": "🔀 Replace {{ variables }} in all your files",

I suspect it may have something to do with my node version, I'm using version v14.13.1

@blakek
Copy link
Contributor

blakek commented Feb 9, 2022

Could you test version 6.0.1? This should be fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants