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

No "exports" main resolved in @babel/helper-compilation-targets/package.json with Node 12.17.0 #11615

Closed
JamesSingleton opened this issue May 26, 2020 · 10 comments
Labels
i: bug i: needs triage outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@JamesSingleton
Copy link

JamesSingleton commented May 26, 2020

Bug Report

I know #11216 mentions a similar issue, but that is with Node 13, this is with the newly released 12.17.0.

Current behavior

Node just released 12.17.0 and now running "build": "babel src -d ./", with the following deps (also installed the latest versions as well and still had the issue)

"@babel/cli": "^7.8.3",
"@babel/core": "^7.8.3",

results in:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main resolved in /Users/singleton/OSS/holocron/node_modules/@babel/helper-compilation-targets/package.json
    at applyExports (internal/modules/cjs/loader.js:491:9)
    at resolveExports (internal/modules/cjs/loader.js:507:23)
    at Function.Module._findPath (internal/modules/cjs/loader.js:635:31)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:953:27)
    at Function.Module._load (internal/modules/cjs/loader.js:842:27)
    at Module.require (internal/modules/cjs/loader.js:1026:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (/Users/singleton/OSS/holocron/node_modules/@babel/preset-env/lib/debug.js:8:33)
    at Module._compile (internal/modules/cjs/loader.js:1138:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

Input Code

"build": "babel src -d ./",

Expected behavior

It should build properly without error as it does on Node 12.16.3.

Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)

  • Filename: babel.config.js
module.exports = function (api) {
  api.cache(true);
  return {
    babelrcRoots: ['.', './packages/*'],
  };
}

Environment

System:
    OS: macOS Mojave 10.14.6
  Binaries:
    Node: 12.17.0 - ~/.nvm/versions/node/v12.17.0/bin/node
    npm: 6.14.4 - ~/.nvm/versions/node/v12.17.0/bin/npm
  Monorepos:
    Lerna: 3.20.2
  npmPackages:
    @babel/cli: ^7.8.3 => 7.8.3 
    @babel/core: ^7.8.3 => 7.8.3 
    babel-preset-amex: ^2.1.0 => 2.2.0 
    eslint: ^6.8.0 => 6.8.0 
    jest: ^25.1.0 => 25.1.0 
    lerna: ^3.20.2 => 3.20.2 

Additional context
It works fine on Node 12.16.3.

@babel-bot
Copy link
Collaborator

Hey @JamesSingleton! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."

@MylesBorins
Copy link
Member

@JamesSingleton I was unable to reproduce locally with the exact same babel config and the following dependencies

  "dependencies": {
    "@babel/cli": "^7.8.4",
    "@babel/core": "^7.9.6"
  }

Do you have an example of the code you are attempting to transpile?

@JamesSingleton
Copy link
Author

@MylesBorins, two repos that I know of that are exhibiting this behavior right now are

@MylesBorins
Copy link
Member

Looks like the issue was an out of date version of helper-compilation-target in the package-lock. I've opened a PR that should fix this.

americanexpress/holocron#35

Once that has confirmed to fix stuff I think this issue can be closed.

@existentialism
Copy link
Member

@MylesBorins thanks for digging in!

@JamesSingleton
Copy link
Author

@MylesBorins what is weird is when I did npm i -D @babel/core@latest I still ran into issues. Did you delete the package-lock.json and then reinstall? I had to copy in your lockfile for it to finally work... weird

@JamesSingleton
Copy link
Author

@MylesBorins going to close this issue, thanks for taking the time to help me out!

@MylesBorins
Copy link
Member

FTR I had to blow away the entire lockfile and run npm install again to get the right dependency graph

@jseminck
Copy link

In my case, the @babel/helper-compilation-targets package is installed as a dependency of @babel/preset-env. Updating it to the latest version fixed the issue for me.

$ npm ls @babel/helper-compilation-targets
└─┬ @babel/preset-env@7.8.3
  └── @babel/helper-compilation-targets@7.8.3

@smilingkite
Copy link

For people trying to deal with this one: I had to not only delete the lock file, but also delete the whole node-modules directory (though deleting the specific package would probably have worked as well).

THEN do an 'npm install'.

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Oct 28, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 28, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: bug i: needs triage outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

No branches or pull requests

6 participants