Morton
Morton

Reputation: 5782

How to upgrade to React Native 0.57.0 version?

I create a project by CRNA and change to be a pure RN project.

When i type comman react-native-git-upgrade and run the project shows the error:

error: bundling failed: Error: ENOENT: no such file or directory, open '/Users/motogod19/MyWork/test_upgrade/node_modules/react-native/node_modules/create-react-class/index.js'

Before upgrade enviroment:

package.json:

{
  "name": "test_upgrade",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {
    "babel-preset-react-native-stage-0": "^1.0.1",
    "jest": "^23.6.0",
    "jest-react-native": "^18.0.0",
    "react-test-renderer": "16.3.1"
  },
  "scripts": {
    "start": "react-native start",
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "test": "jest"
  },
  "jest": {
    "preset": "react-native"
  },
  "dependencies": {
    "react": "16.3.1",
    "react-native": "~0.55.2"
  }
}

.babelrc:

{
  "presets": [
    "babel-preset-react-native-stage-0/decorator-support"
  ],
  "env": {
    "development": {
      "plugins": [
        "transform-react-jsx-source"
      ]
    }
  }
}

After upgrade:

package.json:

{
  "name": "test_upgrade",
  "version": "0.1.0",
  "private": true,
  "devDependencies": {

    "metro-react-native-babel-preset": "0.45.2",
    "jest": "^23.6.0",
    "jest-react-native": "^18.0.0",
    "react-test-renderer": "16.3.1"
  },
  "scripts": {
    "start": "react-native start",
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "test": "jest"
  },
  "jest": {
    "preset": "react-native"
  },
  "dependencies": {
    "react": "16.5.0",
    "react-native": "~0.57.0"
  }
}

.babelrc:

{
  "presets": [
    "module:metro-react-native-babel-preset"
  ],
  "env": {
    "development": {
      "plugins": [
        "transform-react-jsx-source"
      ]
    }
  }
}

I have no idea how to fix it. Any help would be appreciated, thanks in advance.

Step 1: If type npm install create-react-class and run it shows error:

error: bundling failed: Error: Couldn't find preset "module:metro-react-native-babel-preset" relative to directory "/Users/motogod19/MyWork/test_up"
    at /Users/motogod19/MyWork/test_up/node_modules/babel-core/lib/transformation/file/options/option-manager.js:293:19

The option-manager.js line 293 is:

if (typeof val === "string") {
      presetLoc = (0, _resolvePreset2.default)(val, dirname);

      if (!presetLoc) {
        throw new Error("Couldn't find preset " + (0, _stringify2.default)(val) + " relative to directory " + (0, _stringify2.default)(dirname));
      }

      val = require(presetLoc);
    }

Still can't figure it out, thanks in advance.

Upvotes: 2

Views: 4593

Answers (2)

Rareș Pop Sebastian
Rareș Pop Sebastian

Reputation: 11

{
  "presets": ["module:metro-react-native-babel-preset"],
}

after you install module:metro-react-native-babel-preset, you need to put that in your .babelrc file instead of "react-native", they changed this, and are a lot of changes with babel 7, i just made the update, and on emulator it works, but when i install apk on the phone, it crashes immediatly, from what im reading its something with babel helpers... i try to figure out this.. no luck until now.. but for your question, that is the answer https://github.com/facebook/react-native/issues/20150#issue-340235017

Upvotes: 0

Sahesh
Sahesh

Reputation: 885

Run react-native upgrade and run the project.

If it's not working , install that module manually.

npm install create-react-class

Then somewhere in your code, add:

require('create-react-class');

Let me know if you have any issues.

Upvotes: 2

Related Questions