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.
Copyright Notice:Content Author:「Morton」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/52311783/how-to-upgrade-to-react-native-0-57-0-version