facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
118.87k stars 24.3k forks source link

react-native-git-upgrade does not update package.json #13164

Closed quanvuong closed 6 years ago

quanvuong commented 7 years ago

Description

Explain what you did, what you expected to happen, and what actually happens.

I current have react native 41.2. I ran react-native-git-upgrade which ends with The upgrade process succeeded but there might be conflicts to be resolved. See above for the list of files that have merge conflicts. After I fixed the conflict, I ran react-native-git-upgrade which ends with an error react-native version in "package.json" (0.41.2) doesn't match the installed version in "node_modules" (0.42.3).

Reproduction Steps and Sample Code

Try to reproduce your bug on https://sketch.expo.io/ and provide a link. If you can't reproduce the bug on Sketch, provide a sample project. At the very least, provide an example of your code.

Solution

What needs to be done to address this issue? Ideally, provide a pull request with a fix.

Save new version of react-native to package.json

Additional Information

christianversloot commented 7 years ago

Today I upgraded from 0.38 and it changed my package.json.

"react-native": "^0.42.3",

teameh commented 7 years ago

I'm having the same problem.

package.json is not updated after react-native-git-upgrade found some conflicts.

$ react-native-git-upgrade

git-upgrade info Check for updates
git-upgrade info Using yarn 0.17.9
git-upgrade info Read package.json files
git-upgrade info Check declared version
git-upgrade info Check matching versions
git-upgrade info Check React peer dependency
git-upgrade info Check that Git is installed
git-upgrade info Get information from NPM registry
git-upgrade info Upgrading to React Native 0.43.0, React 16.0.0-alpha.6
git-upgrade info Setup temporary working directory
git-upgrade info Configure Git environment
git-upgrade info Init Git repository
git-upgrade info Add all files to commit
    warning: CRLF will be replaced by LF in android/gradlew.bat.
    The file will have its original line endings in your working directory.
git-upgrade info Commit current project sources
git-upgrade info Create a tag before updating sources
git-upgrade info Generate old version template
git-upgrade info Add updated files to commit
git-upgrade info Commit old version template
git-upgrade info Install the new version
    warning Incorrect peer dependency "react@>=15.0.2".
    warning Incorrect peer dependency "react@^0.14.0 || ^15.0.0-0 || ^15.4.0-0".
    warning Incorrect peer dependency "react@^15.4.1".
    warning Incorrect peer dependency "react@>=15.4.0".
    warning Incorrect peer dependency "react@^15.5.0".
git-upgrade info Generate new version template
git-upgrade info Add updated files to commit
    warning: CRLF will be replaced by LF in android/gradlew.bat.
    The file will have its original line endings in your working directory.
git-upgrade info Commit new version template
git-upgrade info Generate the patch between the 2 versions
git-upgrade info Save the patch in temp directory
git-upgrade info Reset the 2 temporary commits
git-upgrade info Apply the patch
    error: patch failed: .gitignore:22
    Falling back to three-way merge...
    Applied patch to '.gitignore' cleanly.
    error: patch failed: ios/MyProject.xcodeproj/project.pbxproj:22
    Falling back to three-way merge...
    Applied patch to 'ios/MyProject.xcodeproj/project.pbxproj' with conflicts.
    error: ios/MyProject.xcodeproj/xcshareddata/xcschemes/MyProject.xcscheme: does not exist in index
git-upgrade WARN The upgrade process succeeded but there might be conflicts to be resolved. See above for the list of files that have merge conflicts.
git-upgrade info Upgrade done

package.json:

"react": "~15.4.0-rc.4",
"react-native": "0.38.0",

There are no conflict delimiters in 'ios/MyProject.xcodeproj/project.pbxproj' btw.. there should be right?

Running the tool again fails because node_modules are already updated by the tool but not package.json?

$ react-native-git-upgrade
git-upgrade info Check for updates
git-upgrade info Using yarn 0.17.9
git-upgrade info Read package.json files
git-upgrade info Check declared version
git-upgrade info Check matching versions
git-upgrade ERR! An error occurred during upgrade:
git-upgrade ERR! Error: react-native version in "package.json" (0.38.0) doesn't match the installed version in "node_modules" (0.43.0).
Try running "yarn" to fix this.
    at checkMatchingVersions (/usr/local/lib/node_modules/react-native-git-upgrade/checks.js:24:11)
    at Object.<anonymous> (/usr/local/lib/node_modules/react-native-git-upgrade/cliEntry.js:253:5)
    at Generator.next (<anonymous>)
    at step (/usr/local/lib/node_modules/react-native-git-upgrade/cliEntry.js:171:191)
    at /usr/local/lib/node_modules/react-native-git-upgrade/cliEntry.js:171:361
    at tryCallOne (/usr/local/lib/node_modules/react-native-git-upgrade/node_modules/promise/lib/core.js:37:12)
    at /usr/local/lib/node_modules/react-native-git-upgrade/node_modules/promise/lib/core.js:123:15
    at flush (/usr/local/lib/node_modules/react-native-git-upgrade/node_modules/asap/raw.js:50:29)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

Starting over by rm -rf node_modules yields the same results.

irrigator commented 7 years ago

@tiemevanveen

error: ios/MyProject.xcodeproj/xcshareddata/xcschemes/MyProject.xcscheme: does not exist in index

That might be the problem. I had a similar error ("xxx does not exist in index) because I changed the location of a Java file. I guess that maybe react-native-git-upgrade can't handle this kind of error correctly, thus leaving the upgrade process in an inconsistent state.

olgertse commented 7 years ago

I managed to solve the does not exist in index problem by changing the name field in package.json to match the project directory name.

vincent1988 commented 7 years ago

+1

developdeez commented 7 years ago

Have the same error. ran npm install as it said and nothing

brunoosilva commented 7 years ago

@quanvuong

For the error react-native version in "package.json" (0.41.2) doesn't match the installed version in "node_modules" (0.42.3).

Try run yarn and react-native-git-upgrade again.

For the error does not exist in index, change project name in package.json, as said by @od1k

giulianok commented 7 years ago

Same here, working on version 0.48.4, trying to update using react-native-git-upgrade. It doesn't upgrade the deps in package.json, but in node_modules I have 0.49.2 installed

djalmaaraujo commented 7 years ago

anyone fixed this?

ScreamZ commented 7 years ago

Do you have any answer to this too ? I stuck with it...

daiyunchao commented 7 years ago

+1

djalmaaraujo commented 7 years ago

@ScreamZ I ran the update but updated the package.json myself.

ScreamZ commented 7 years ago

@djalmaaraujo Yeah, but when I try using the tool, it looks like it updated the node_nodules, not the package.json. But it's like the tool is reverting what he done, because i've no conflicts displayed in the given file that are supposed to have one...

djalmaaraujo commented 7 years ago

@ScreamZ That's the issue here, it does not update the package.json, but updates the dependencies..

Jacse commented 6 years ago

I ended up updating react native manually by consulting RNDiff. Worked out quite well, the changes are few.

akoufa commented 6 years ago

I think this is related to this https://github.com/facebook/react-native/issues/12112#issuecomment-284491701 . If you search for the patch and apply it yourself then it will update the package.json and try to update the other files too.

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Maybe the issue has been fixed in a recent release, or perhaps it is not affecting a lot of people. If you think this issue should definitely remain open, please let us know why. Thank you for your contributions.