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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]:Cannot read property 'file' of undefined #15753

Closed
1 task
jisao opened this issue Jul 6, 2023 · 9 comments
Closed
1 task

[Bug]:Cannot read property 'file' of undefined #15753

jisao opened this issue Jul 6, 2023 · 9 comments
Labels
i: needs triage outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@jisao
Copy link

jisao commented Jul 6, 2023

馃捇

  • Would you like to work on a fix?

How are you using Babel?

babel-loader (webpack)

Input code

    "@babel/core": "7.9.0",
    "@babel/helper-create-regexp-features-plugin": "7.22.6",
    "@babel/helper-plugin-utils": "7.22.5",
    "@babel/plugin-proposal-class-properties": "7.8.3",
    "@babel/plugin-proposal-decorators": "7.8.3",
    "@babel/plugin-syntax-jsx": "7.22.5",
    "@babel/plugin-transform-runtime": "7.22.6",
    "@babel/polyfill": "7.12.1",
    "@babel/preset-env": "7.9.0",
    "@babel/preset-react": "7.22.5",
    "@babel/preset-stage-0": "7.8.3",
    "@babel/preset-typescript": "7.22.5",
    "babel-eslint": "10.0.3",
    "babel-jest": "24.9.0",
    "babel-loader": "8.0.6",
    "babel-plugin-import": "1.13.6",
    "babel-preset-react-app": "9.1.2",
   "happypack": "5.0.1",
    "webpack": "4.46.0",
    "webpack-bundle-analyzer": "4.9.0",
    "webpack-cli": "3.3.12",
    "webpack-dev-server": "3.11.3",
    "webpackbar": "4.0.0"

Configuration file name

.babelrc

Configuration

{
"presets": [["@babel/preset-env", { "modules": false, "useBuiltIns": "usage", "corejs": "3" }], "@babel/preset-react", "@babel/preset-typescript"],
"plugins": [
["import", { "libraryName": "antd", "libraryDirectory": "es", "style": true }],
"@babel/transform-runtime",
["@babel/plugin-proposal-decorators", { "legacy": true }],
"@babel/plugin-proposal-class-properties"
],

"comments": false,
"env": {
    "test": {
        "presets": ["@babel/preset-env", "@babel/preset-stage-0", "@babel/preset-react"],
        "plugins": ["@babel/plugin-transform-runtime"]
    }
}

}

Current and expected behavior

ERROR in ./src/entry/index/index.js
Module build failed (from ./node_modules/happypack/loader.js):
TypeError: /Users/xiaoheshang/Desktop/his/his/hospitalization_doctor_station/src/entry/index/index.js: Cannot read property 'file' of undefined
at Object.usagePure (/Users/xiaoheshang/Desktop/his/his/hospitalization_doctor_station/node_modules/babel-plugin-polyfill-regenerator/lib/index.js:35:48)
at callProvider (/Users/xiaoheshang/Desktop/his/his/hospitalization_doctor_station/node_modules/@babel/helper-define-polyfill-provider/lib/index.js:178:27)
at PluginPass.ReferencedIdentifier (/Users/xiaoheshang/Desktop/his/his/hospitalization_doctor_station/node_modules/@babel/helper-define-polyfill-provider/lib/visitors/usage.js:25:7)
at PluginPass.newFn (/Users/xiaoheshang/Desktop/his/his/hospitalization_doctor_station/node_modules/@babel/traverse/lib/visitors.js:192:17)
at newFn (/Users/xiaoheshang/Desktop/his/his/hospitalization_doctor_station/node_modules/@babel/traverse/lib/visitors.js:159:14)
at NodePath._call (/Users/xiaoheshang/Desktop/his/his/hospitalization_doctor_station/node_modules/@babel/traverse/lib/path/context.js:46:20)
at NodePath.call (/Users/xiaoheshang/Desktop/his/his/hospitalization_doctor_station/node_modules/@babel/traverse/lib/path/context.js:36:17)
at NodePath.visit (/Users/xiaoheshang/Desktop/his/his/hospitalization_doctor_station/node_modules/@babel/traverse/lib/path/context.js:82:31)
at TraversalContext.visitQueue (/Users/xiaoheshang/Desktop/his/his/hospitalization_doctor_station/node_modules/@babel/traverse/lib/context.js:86:16)
at TraversalContext.visitSingle (/Users/xiaoheshang/Desktop/his/his/hospitalization_doctor_station/node_modules/@babel/traverse/lib/context.js:65:19)

Environment

All projects started or packaged locally today with this issue

Possible solution

No response

Additional context

No response

@babel-bot
Copy link
Collaborator

Hey @jisao! 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.

@Sapython
Copy link

Sapython commented Jul 6, 2023

Angular is also broken because of this issue. angular/angular-cli#25496

@nicolo-ribaudo
Copy link
Member

Can you still reproduce this issue with version 7.22.8 of @babel/core and @babel/traverse?

@Sapython
Copy link

Sapython commented Jul 6, 2023

It's fixed with babel version 7.22.8 of @bable/core. For angular I deleted by package-lock.json and node_modules to resolve it.

@jisao
Copy link
Author

jisao commented Jul 6, 2023

Using @bable/core version 7.22.8 can solve this problem

@mshima
Copy link

mshima commented Jul 6, 2023

It was not fixed for our use case.
The error was introduced before babel v7.22.7, not sure if at v7.22.6 or a transitive dependency. First failure is from 18 hours ago (before v7.22.7) https://github.com/jhipster/generator-jhipster-react-native/actions/runs/5467660427/jobs/9954258684.
I've updated a working package-lock to @babel/core@7.22.6 and it's working as expected. Recreating package-lock breaks the test (before v7.22.7).
I am pretty sure @babel/transform by itself is not the root cause. v7.22.7 may have triggered for others use cases.

For some reason babel is behaving something like:

  function foo(bar) { // passing bar = {}
    console.log(bar.foo); // prints foo
    console.log(bar.nonExisting); // prints nonExisting
  }

@logancooper-tylertech
Copy link

We were seeing this issue on 7.22.27 last night, but it appears to have been resolved by pulling 7.22.28

@nicolo-ribaudo
Copy link
Member

@mshima That looks like a different issue, since the error is thrown by the generated code and not while compiling. Could you open a new issue, with steps I can use to reproduce it?

@milesyang0220
Copy link

milesyang0220 commented Jul 7, 2023

For me, manually installing @babel/traverse@7.22.6 is a potential workaround solution. My project 'luckily' has two versions of @babel/traverse, it was updated from 7.22.6 to 7.22.7. It was difficult to identify this problem because the bot released the package without any tags yesterday.

@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 Feb 10, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
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

8 participants