镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Errors from conditional exports after upgraded to Node 13.13 #32852

Description

@JLHwung
  • Version: Node.js 13.13
  • Platform: 19.4.0 Darwin Kernel Version 19.4.0
  • Subsystem: ES modules

What steps will reproduce the bug?

npm install @babel/compat-data
node -e "require('@babel/compat-data/corejs3-shipped-proposals')"

What is the expected behavior?

It should load the module as expected in Node.js 13.12

What do you see instead?

Error: Cannot find module '@babel/compat-data/corejs3-shipped-proposals'
Require stack:
- /tmp/[eval]
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:952:15)
    at Function.resolve (internal/modules/cjs/helpers.js:78:19)
    at [eval]:1:9
    at Script.runInThisContext (vm.js:131:20)
    at Object.runInThisContext (vm.js:297:38)
    at Object.<anonymous> ([eval]-wrapper:10:26)
    at Module._compile (internal/modules/cjs/loader.js:1123:30)
    at evalScript (internal/process/execution.js:94:25)
    at internal/main/eval_string.js:23:3 {
  code: 'MODULE_NOT_FOUND',
  requireStack: [ '/tmp/[eval]' ]
}

Additional information

Caught by the Babel CI: https://travis-ci.com/github/babel/babel/jobs/319348116#L360

The regression was likely introduced in #32351.

The file structure of @babel/compat-data can be simplified w.l.o.g as

package.json
corejs3-shipped-proposals.js
data/corejs3-shipped-proposals.json

and the package.json:

"exports": {
  "./corejs3-shipped-proposals": "./data/corejs3-shipped-proposals.json"
}

The corejs3-shipped-proposals.js is a proxy which delegates to "./data/corejs3-shipped-proposals.json" for Node.js < 13.3 support.

module.exports = require("./data/corejs3-shipped-proposals.json");

Activity

  1. JLHwung commented on Apr 14, 2020

    @JLHwung
    ContributorAuthor
  2. guybedford commented on Apr 14, 2020

    @guybedford
    Contributor

    @JLHwung I created babel/babel#11283 specifically to avoid Babel having this error. Was the above fix not patched and released already?

  3. JLHwung commented on Apr 14, 2020

    @JLHwung
    ContributorAuthor

    @guybedford Ahh thanks. It was release in 7.9.0.

    For those babel users who are affected by this issue after upgrading to node.js 13.13/12.17, please upgrade @babel/preset-env to 7.9.0.

  4. guybedford commented on Apr 14, 2020

    @guybedford
    Contributor

    Great, I'm glad the early fix here could help!

  5. added a commit that references this issue on May 9, 2020
  6. nandorojo commented on May 16, 2020

    @nandorojo

    I had this problem in building a React Native Bob library. I solved it using nvm install 13.12, which downgraded my node to 13.12.

    This solution only applies if you use nvm to manage your Node versions (if you don't I recommend it!)

  7. added a commit that references this issue on May 25, 2020
  8. mamoonraja commented on May 28, 2020

    @mamoonraja

    FYI, I noticed the same issue in 12.17.x. We have to switch to 12.6.x in Travis for now.

  9. added a commit that references this issue on Jun 2, 2020
  10. added a commit that references this issue on Jun 8, 2020
  11. 2 remaining items

  12. added a commit that references this issue on Jun 11, 2020
  13. added a commit that references this issue on Jun 16, 2020
  14. added a commit that references this issue on Jun 24, 2020
  15. added a commit that references this issue on Jul 28, 2020
  16. added a commit that references this issue on Sep 9, 2020
  17. added a commit that references this issue on Jul 6, 2021
  18. AndersDJohnson commented on Sep 17, 2021

    @AndersDJohnson

    Ran into similar problem, though on a later Node version and using yarn not npm, but this worked for me:

    yarn upgrade --scope @babel
    
  19. cluis13915 commented on Sep 3, 2024

    @cluis13915

    Ran into similar problem, though on a later Node version and using yarn not npm, but this worked for me:

    yarn upgrade --scope @babel
    

    This worked for me. Thanks!

    ember-cli: 3.4.4
    node: 12.22.12
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions