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 properties of undefined (reading 'node') #14822

Closed
1 task
evk8 opened this issue Aug 3, 2022 · 13 comments 路 Fixed by #14825
Closed
1 task

[Bug]: Cannot read properties of undefined (reading 'node') #14822

evk8 opened this issue Aug 3, 2022 · 13 comments 路 Fixed by #14825
Labels
i: bug i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@evk8
Copy link

evk8 commented Aug 3, 2022

馃捇

  • Would you like to work on a fix?

How are you using Babel?

babel-loader (webpack)

Input code

What was successful on July 26th is now failing.
If I remove '@babel/preset-env' it works fine.

local build is fine!
but, It happens in docker environment.

docker version : 4.10.1 (82475)
node:16-alpine

#15 183.9 TypeError: Cannot read properties of undefined (reading 'node')
#15 183.9     at plainFunction (/app/node_modules/@babel/plugin-transform-async-to-generator/node_modules/@babel/helper-wrap-function/lib/index.js:69:17)
#15 183.9     at wrapFunction (/app/node_modules/@babel/plugin-transform-async-to-generator/node_modules/@babel/helper-wrap-function/lib/index.js:128:5)
#15 183.9     at _default (/app/node_modules/@babel/plugin-transform-async-to-generator/node_modules/@babel/helper-remap-async-to-generator/lib/index.js:47:35)
#15 183.9     at PluginPass.Function (/app/node_modules/@babel/plugin-transform-async-to-generator/lib/index.js:55:50)
#15 183.9     at i (/app/node_modules/next/dist/compiled/babel/bundle.js:1890:373015)
#15 183.9     at NodePath._call (/app/node_modules/next/dist/compiled/babel/bundle.js:1890:292626)
#15 183.9     at NodePath.call (/app/node_modules/next/dist/compiled/babel/bundle.js:1890:292450)
#15 183.9     at NodePath.visit (/app/node_modules/next/dist/compiled/babel/bundle.js:1890:293401)
#15 183.9     at TraversalContext.visitQueue (/app/node_modules/next/dist/compiled/babel/bundle.js:1890:286761)
#15 183.9     at TraversalContext.visitMultiple (/app/node_modules/next/dist/compiled/babel/bundle.js:1890:286362)

Configuration file name

babel.config.js

Configuration

const config = {
  presets: [
    [
      'next/babel',
    ],
    [
      '@babel/preset-env',
      {
        debug: true,
        useBuiltIns: 'usage',
        corejs: 3,
      }
    ]
  ],
  plugins: [
    'transform-class-properties',
    ['@babel/plugin-proposal-decorators', { legacy: true }],
    ['styled-components', { ssr: true }],
    ['@babel/plugin-transform-runtime', { corejs: 3 }],
    ['inline-react-svg'],
    '@emotion/babel-plugin',
  ],
};

module.exports = config;

Current and expected behavior

Environment

 System:
    OS: macOS 12.4
  Binaries:
    Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 8.11.0 - ~/.nvm/versions/node/v16.16.0/bin/npm
  npmPackages:
    @babel/core: 7.12.13 => 7.12.13 
    @babel/helper-function-name: 7.15.4 => 7.15.4 
    @babel/helper-remap-async-to-generator: 7.15.4 => 7.15.4 
    @babel/helper-wrap-function: 7.15.4 => 7.15.4 
    @babel/parser: 7.15.8 => 7.15.8 
    @babel/plugin-transform-object-assign: 7.12.13 => 7.12.13 
    @babel/plugin-transform-runtime: 7.13.10 => 7.13.10 
    @babel/preset-env: 7.17.12 => 7.17.12 
    @babel/preset-typescript: 7.12.13 => 7.12.13 
    @babel/types: 7.15.4 => 7.15.4 
    babel-jest: 27.5.1 => 27.5.1 
    babel-loader: 8.1.0 => 8.1.0 
    babel-plugin-inline-react-svg: ^2.0.1 => 2.0.1 
    babel-plugin-module-resolver: ^4.1.0 => 4.1.0 
    babel-plugin-styled-components: ^2.0.2 => 2.0.7 
    babel-plugin-transform-class-properties: ^6.24.1 => 6.24.1 
    babel-plugin-transform-remove-console: ^6.9.4 => 6.9.4 
    eslint: 8.15.0 => 8.15.0 
    jest: 27.5.1 => 27.5.1 

Possible solution

No response

Additional context

local build is fine!
but, It happens in docker environment.

docker version : 4.10.1 (82475)
node:16-alpine

No response

@babel-bot
Copy link
Collaborator

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

@evk8 evk8 changed the title [Bug]: [Bug]: Cannot read properties of undefined (reading 'node') Aug 3, 2022
@nicolo-ribaudo
Copy link
Member

#14752 (comment)

This is a compatibility issue between new @babel/helper-wrap-function versions and old @babel/traverse versions. As a workaround, update @babel/traverse (you might need to delete it from your lockfile and re-install your dependencies)

A good enough fix might be to add ?? path after https://github.com/babel/babel/pull/14752/files#diff-13301793f9705926efa934907a80c6d92342813613d1ef42e638f21158d395d9R100 to fallback to the old (buggy, but not crashing) behavior, but writing a test is going to be hard.

I cannot work on this until the weekend, so if someone else wants to do it please do so!

@evk8
Copy link
Author

evk8 commented Aug 3, 2022

new install version

System:
OS: macOS 12.4
Binaries:
Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 8.11.0 - ~/.nvm/versions/node/v16.16.0/bin/npm
npmPackages:
@babel/core: 7.18.10 => 7.18.10
@babel/plugin-transform-object-assign: 7.18.6 => 7.18.6
@babel/plugin-transform-runtime: 7.18.10 => 7.18.10
@babel/preset-env: 7.18.10 => 7.18.10
@babel/preset-typescript: 7.18.6 => 7.18.6
@babel/traverse: 7.18.6 => 7.18.6
babel-jest: 27.5.1 => 27.5.1
babel-loader: 8.1.0 => 8.1.0
babel-plugin-inline-react-svg: ^2.0.1 => 2.0.1
babel-plugin-module-resolver: ^4.1.0 => 4.1.0
babel-plugin-styled-components: ^2.0.2 => 2.0.7
babel-plugin-transform-class-properties: ^6.24.1 => 6.24.1
babel-plugin-transform-remove-console: ^6.9.4 => 6.9.4
eslint: 8.15.0 => 8.15.0
jest: 27.5.1 => 27.5.1

Likewise, I get an error.
with docker envirenment.

case1. it's fine!

'@babel/preset-env',
      {
        debug: true,
        useBuiltIns: 'usage',
        corejs: { version: 3 },
        targets: {
          node: true
        },
      },

case2, it's error!

'@babel/preset-env',
      {
        debug: true,
        useBuiltIns: 'usage',
        corejs: { version: 3 },
        targets: {
          browsers: ['current node', 'chrome >= 44', 'android >= 6', 'firefox >= 38', 'ios_saf >= 9', ' safari >= 9']
        },
      },

@JLHwung
Copy link
Contributor

JLHwung commented Aug 3, 2022

@babel/traverse: 7.18.6 => 7.18.6

Please upgrade @babel/traverse to 7.18.10, or you can wait for the fix in #14825.

@evk8
Copy link
Author

evk8 commented Aug 3, 2022

new install version

System:
OS: macOS 12.4
Binaries:
Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 8.11.0 - ~/.nvm/versions/node/v16.16.0/bin/npm
npmPackages:
@babel/core: 7.18.10 => 7.18.10
@babel/plugin-transform-object-assign: 7.18.6 => 7.18.6
@babel/plugin-transform-runtime: 7.18.10 => 7.18.10
@babel/preset-env: 7.18.10 => 7.18.10
@babel/preset-typescript: 7.18.6 => 7.18.6
@babel/traverse: 7.18.10 => 7.18.10
babel-jest: 27.5.1 => 27.5.1
babel-loader: 8.1.0 => 8.1.0
babel-plugin-inline-react-svg: ^2.0.1 => 2.0.1
babel-plugin-module-resolver: ^4.1.0 => 4.1.0
babel-plugin-styled-components: ^2.0.2 => 2.0.7
babel-plugin-transform-class-properties: ^6.24.1 => 6.24.1
babel-plugin-transform-remove-console: ^6.9.4 => 6.9.4
eslint: 8.15.0 => 8.15.0
jest: 27.5.1 => 27.5.1

Likewise, I get an error.
I suspect it conflicts with the nextjs preset configuration .

Can you check if there is a possible conflict with the nextjs environment setting?
Be sure to test it in docker environment.

it's fine case!

[
      'next/babel',
      {
        'preset-env': {
          debug: true,
          useBuiltIns: 'usage',
          corejs: { version: 3 },
          targets: {
            browsers: ['current node','chrome >= 44', 'android >= 6', 'firefox >= 38', 'ios_saf >= 9', ' safari >= 9'],
          },
        },
      },
    ],
/*[
      '@babel/preset-env',
      {
        debug: true,
        useBuiltIns: 'usage',
        corejs: { version: 3 },
        targets: {
          browsers: ['current node','chrome >= 44', 'android >= 6', 'firefox >= 38', 'ios_saf >= 9', ' safari >= 9'],
        },
      },
    ],*/

@ZxBing0066
Copy link

I add overrides to package.json to resolve this temporarily.

 "overrides": {
   "@babel/helper-wrap-function": "7.18.9"
 }

@liuxingbaoyu
Copy link
Member

@ZxBing0066 Can you try upgrading @babel/traverse?

@ZxBing0066
Copy link

@ZxBing0066 Can you try upgrading @babel/traverse?

@babel/traverse is already the latest version: 7.18.10.

@liuxingbaoyu
Copy link
Member

Can anyone provide a reproducible minimal code or repo?

@evk8
Copy link
Author

evk8 commented Aug 4, 2022

If you use the nextjs pure version, there seems to be no problem.
It's not exact, but it seems to happen when webpack and babel alias are set.
Since we confirmed the customized version, we will close the issue for now.
Thanks for checking them all out.

@evk8 evk8 closed this as completed Aug 4, 2022
@evk8
Copy link
Author

evk8 commented Aug 4, 2022

Can anyone provide a reproducible minimal code or repo?

We will reply you after work.

@JLHwung
Copy link
Contributor

JLHwung commented Aug 4, 2022

Fixed in @babel/helper-wrap-function 7.18.11.

@evk8
Copy link
Author

evk8 commented Aug 5, 2022

Fixed in @babel/helper-wrap-function 7.18.11.

Just using "@babel/traverse": "7.18.11" fixed the error.
Still using "@babel/helper-wrap-function":"7.18.6". We will also change to the latest version. Thanks for your help.

@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 Nov 4, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 4, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
i: bug i: regression outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants