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

(Node >16, RN <0.68) Metro has encountered an error: Cannot read properties of undefined (reading 'transformFie'): . . . #790

Closed
nabtron opened this issue Mar 13, 2022 · 27 comments
Assignees

Comments

@nabtron
Copy link

nabtron commented Mar 13, 2022

Error while running react-native app on ios.

react-native version: 0.67.3

Metro has encountered an error: Cannot read properties of undefined (reading 'transformFie'): . . .

Tried changing node version to 17, 16.12, 14, etc. but no use.

Please help / guide. Thanks.

Screenshot 2022-03-13 at 7 42 31 PM

detailed error:

Metro has encountered an error: Cannot read properties of undefined (reading 'transformFile'): node_modules/metro/src/Bundler.js (48:30)

RCTFatal
__28-[RCTCxxBridge handleError:]_block_invoke
_dispatch_call_block_and_release
_dispatch_client_callout
_dispatch_main_queue_callback_4CF
__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__
__CFRunLoopRun
CFRunLoopRunSpecific
GSEventRunModal
-[UIApplication _run]
UIApplicationMain
main
start_sim
0x0

@daihovey

This comment has been minimized.

@cosmosinnovate
Copy link

cosmosinnovate commented Mar 14, 2022

I am running into the same issues as above.

Screen Shot 2022-03-14 at 1 54 17 PM

@robhogan robhogan self-assigned this Mar 14, 2022
@robhogan
Copy link
Contributor

Could someone who's experiencing this please post:

  • Output of yarn list or npm list -a
  • Contents of metro.config.js
  • Contents of babel.config.js

This does look like we're trying to use Bundler._transformer before it's set, but although this code lives on the edge (relying on ordering of promise branches) - it should be ok, and I haven't been able to reproduce.

@nabtron
Copy link
Author

nabtron commented Mar 18, 2022

metro.config.js

/**
 * Metro configuration for React Native
 * https://github.com/facebook/react-native
 *
 * @format
 */

module.exports = {
  transformer: {
    getTransformOptions: async () => ({
      transform: {
        experimentalImportSupport: false,
        inlineRequires: true,
      },
    }),
  },
};

babel.config.js

module.exports = {
  presets: ['module:metro-react-native-babel-preset'],
};

npm list -a is huge, with only one possible warning in it:

─┬ react-native-permissions@3.3.1
│ ├── UNMET OPTIONAL DEPENDENCY react-native-windows@>=0.62.0
│ ├── react-native@0.67.4 deduped
│ └── react@17.0.2 deduped

No other error.

@robhogan
Copy link
Contributor

robhogan commented Mar 18, 2022

Thanks @nabtron

npm list -a is huge, with only one possible warning in it

I'm actually more interested in the package versions you have - my working theory is that this might be a transform bug in a recent minor dependency update, causing promise branches to execute out of order. That's partly because a cluster of recent reports against an old Metro version suggests the issue is in a recently released dependency rather than Metro itself.

You could post the output to a gist if you like, or filter down to babel-, @babel and metro- dependencies and post the versions here. Equivalently, uploading your package-lock.json would work.

Are you still regularly seeing this issue?

@nabtron
Copy link
Author

nabtron commented Mar 18, 2022

@rh389

package-lock.json: https://gist.github.com/nabtron/3ab61e930e3ad997deaa54e294c3e154

@kidtzz
Copy link

kidtzz commented Mar 21, 2022

This work for me

export NODE_OPTIONS=--openssl-legacy-provider

and i'm not downgrade my node

my node 17.7.1

i'm just install same node from package.json => dependencies => node on folder project react-native

@nabtron
Copy link
Author

nabtron commented Mar 22, 2022

@kidtzz so issue is with metro or openssl?

@NaveenSubburaj

This comment has been minimized.

@nabtron

This comment has been minimized.

@alex27riva

This comment has been minimized.

@itta611
Copy link

itta611 commented Jul 13, 2022

Hi!
I solved this issue with downgrading node version. (In my case, v17.4.0 -> v16.13.0)

nodebrew install-binary 16.13.0
nodebrew use 16.13.0
npx react-native run-ios

@robhogan
Copy link
Contributor

Yes, this is down to incompatibility of older versions of Metro with Node 17+. Contrary to the original issue report here, I haven't seen a reproduction for Node <17. The root cause is Node 17 using OpenSSL 3 (nodejs/node#40455), which drops support for MD4 hashing, which we used until #752.

Three options:

  • Update to React Native 0.68 (Metro 0.67) or higher. That includes the Metro fix for Node 17+ compatibility.
  • Use Node 16 or older.
  • Set NODE_OPTIONS=--openssl-legacy-provider

@ez-tech-global
Copy link

This work for me

export NODE_OPTIONS=--openssl-legacy-provider

and i'm not downgrade my node

my node 17.7.1

i'm just install same node from package.json => dependencies => node on folder project react-native

It works for me too! thanks

@ChiuMungZitAlexander
Copy link

I solved this by switching to node v16.

fengken pushed a commit to fengken/RN-Tutorial-Main that referenced this issue Jan 13, 2023
    facebook/react-native#35210

    a. delete node_modules directory
    b. yarn install
    c. cd android; gradlew.bat clean

2. add Environment Variable
    facebook/metro#790
    NODE_OPTIONS=--openssl-legacy-provider

    d. npx react-native run-android
@Leleka14

This comment has been minimized.

@nabtron

This comment has been minimized.

@haveamission

This comment has been minimized.

@Jamal-ReachFirst

This comment has been minimized.

@Jamal-ReachFirst

This comment has been minimized.

@akshitdandyan

This comment has been minimized.

@Mihai-github

This comment has been minimized.

@Dipali711

This comment has been minimized.

@yorickshan

This comment has been minimized.

@Martyneris

This comment has been minimized.

@ParveshPrimotech

This comment has been minimized.

@robhogan robhogan changed the title Metro has encountered an error: Cannot read properties of undefined (reading 'transformFie'): . . . (Node >16, RN <0.68) Metro has encountered an error: Cannot read properties of undefined (reading 'transformFie'): . . . Aug 23, 2024
@robhogan
Copy link
Contributor

There are multiple possible root causes to this message, which indicates the transformer failed to load.

The cause at the time this issue was opened has been fixed for more than a year, and anyone still seeing this is likely experiencing a different bug for which we'll need details on how to reproduce. There's no way we can help with "+1" type responses. Please do open a new issue, and we can give this a fresh look.

@Martyneris - that's a different message and definitely not the same issue. Feel free to open a new one with a reproduction.

I'm locking this because the original root cause here is fixed, but please don't be discouraged from opening a new issue.

@facebook facebook locked and limited conversation to collaborators Aug 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests