metro: Packager error: "Can't find variable: process"

Do you want to request a feature or report a bug? Bug

Behavior The issue was initially discovered in #65 after people began using the latest metro-bundler 0.20.0 version to work around dynamic requires in packages like moment.js

Packager throws the following error when bundling:

Unhandled JS Exception: Can't find variable: process

Repro Steps

  1. Add metro-bundler 0.20.0 to package.json as a “resolutions” entry for react-native:
"resolutions": {
  "react-native/metro-bundler": "0.20.0"
}
  1. Run react-native run-ios as normal.

NOTE: The fact that this issue manifested for people in metro-bundler@0.20.0 is a red herring. This issue appears to be happening with older versions of metro-bundler as well. I’ve confirmed the same error appears in metro-bundler@0.19.0. I haven’t tried to reproduce it in any versions older than 0.19.0 yet.

Environment Node: v8.5.0

package.json

  "dependencies": {
    "react": "16.0.0-beta.5",
    "react-native": "0.49.3"
  },
  "resolutions": {
    "react-native/metro-bundler": "0.19.0"  
  },

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 10
  • Comments: 35 (8 by maintainers)

Most upvoted comments

@richardgirges Any updates on this ?

@PvanHengel updating to RN 0.50.3 fixed this for me… hopefully fixes for you too.

Can confirm that 0.50.2 has this error. It only happens on release build for me though.

+1

We are seeing the same release build issue in ios, we didn’t have any issues with the debug build. The Unhandled JS Exception: undefined is not an object (evaluating 'e.length')', reason: 'Unhandled JS Exception: undefined is not an object (evaluating 'e.length') is a major blocker, do we need to open another issue for that here, or should we keep this one open?

It seems to fix Debug build (which can be run on ios devices now), however there is another Release build issue now: https://github.com/facebook/react-native/issues/16745

Ok, I’ve just actually been able to reproduce it, a fix is coming

On RN0.50.4, with metro-bundle@0.20.3 I am having this issue.

Thanks @nsipplswezey for shedding some light. In fact, package manager lock files will prevent updating to the metro version that fixed this issue (v0.20.3).

For anyone stumbling across this issue, remove the metro entry in your package-lock.json/yarn.lock file and npm install/yarn install again

On 0.50.4 I am having this issue. b27493c0-ccaa-4671-ae19-a770232e1233

I’m on 0.50.3 and I am still experiencing this issue.

Upgrading to RN 0.50.3 fixed this same issue for me too with a new project created this week! I hope upgrading fixes this for you all as well, and if you haven’t done it before here’s the doc: https://facebook.github.io/react-native/docs/upgrading.html cheers!