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

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in... error #26

Open
samwightt opened this issue Feb 28, 2021 · 10 comments

Comments

@samwightt
Copy link

Getting an error when I try to use estree-walker with esbuild:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /Users/sam/Nine/components/node_modules/estree-walker/package.json
    at throwExportsNotFound (internal/modules/esm/resolve.js:290:9)
    at packageExportsResolve (internal/modules/esm/resolve.js:479:7)
    at resolveExports (internal/modules/cjs/loader.js:432:36)
    at Function.Module._findPath (internal/modules/cjs/loader.js:472:31)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:867:27)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/Users/sam/Nine/components/dist/src/main.js:43:39)
    at Module._compile (internal/modules/cjs/loader.js:1063:30) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

Node Version: v14.15.4

tsconfig.json:

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "allowJs": true,
    "importHelpers": true,
    "alwaysStrict": true,
    "sourceMap": true,
    "forceConsistentCasingInFileNames": true,
    "noFallthroughCasesInSwitch": true,
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "noImplicitAny": false,
    "noImplicitThis": false,
    "strictNullChecks": false
  },
  "include": ["src/**/*", "__tests__/**/*"]
}
@Timmmm
Copy link

Timmmm commented Mar 1, 2021

I get the exact same issue, seems like it is nothing to do with esbuild:

$ npm i estree-walker

up to date, audited 268 packages in 4s

37 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

 $ node
Welcome to Node.js v14.5.0.
Type ".help" for more information.
> require('estree-walker')
Uncaught:
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main resolved in /Users/me/myproject/node_modules/estree-walker/package.json
    at resolveExportsTarget (internal/modules/cjs/loader.js:603:11)
    at applyExports (internal/modules/cjs/loader.js:461:14)
    at resolveExports (internal/modules/cjs/loader.js:514:23)
    at Function.Module._findPath (internal/modules/cjs/loader.js:642:31)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1017:27)
    at Function.Module._load (internal/modules/cjs/loader.js:899:27)
    at Module.require (internal/modules/cjs/loader.js:1090:19)
    at require (internal/modules/cjs/helpers.js:75:18)
    at repl:1:1
    at Script.runInThisContext (vm.js:131:18) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

@Timmmm
Copy link

Timmmm commented Mar 1, 2021

Downgrading to 2.0.2 fixes it, and there don't appear to have been any code changes between 2.0.2 and 3.0.0 - just packaging changes so I guess those broke it somehow.

@swernerx
Copy link

Same error in my environment!

swernerx added a commit to sebastian-software/preppy that referenced this issue Mar 17, 2021
@codepunkt
Copy link

Same here.

@guilhermetod
Copy link

I guess this package is not planned to be used in a CommonJS module anymore. It's written as a ES Module and published directly from the src, so it's necessary to use "type": "module" in package.json and convert your package to esm or use a custom resolver.

To test it in the cli:

import('estree-walker').then((m) => console.log(m))

The only thing I found weird is that there's still a "package.json" file under the "src" folder published. You'll only see this by installing the package and inspecting the node_modules since it's not in the repo and is not generated by the build process. I guess it was a left over in the pc of the person who published the last version, since there's no cleaning script pre-publish. This broke my ESLint module resolution for the import/export plugin and removing that file solved it.

@binvb
Copy link

binvb commented Dec 23, 2021

same here, any progress? version@2.0.2 is fine,thank you

@Wallacy
Copy link

Wallacy commented Jun 25, 2022

Same issue using TSX and MDX.

@flipkickmedia
Copy link

v3.0.1 - same problem. Can we get an es and cjs build plz?

This has been going on since 21st Feb 2021. Ill fork the repo and fix it.

@cyco130
Copy link

cyco130 commented Nov 16, 2022

This is an ESM only package now. But it's still possible to use it from CJS: You will have to use dynamic imports like this:

const { walk } = await import("estree-walker");
walk(...);

@eight04
Copy link

eight04 commented Nov 21, 2022

The usage example on README.md doesn't work at all. At least update the readme if you are dropping cjs support.

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

10 participants