0
npm ERR! Merge conflict detected in your package.json.
npm ERR! Please resolve the package.json conflict to retry the command:

I have tried the npm-merge-driver but still coming the same error.

asker
  • 7
  • 5
  • 3
    You either got a merge conflict after the pull and you need to resolve it, or somebody committed a package.json file *with* the merge conflict into it. In either case, it's likely not solvable by any packages but the file needs to be repaired manually. If it's a merge conflict after pull, then resolving that should be easy. – VLAZ May 27 '20 at 19:59
  • Thank you @VLAZ. Could you tell me how can I spot the error to repair on package.json? – Eveline Rojas May 27 '20 at 21:37
  • You can manually look at `package.json` file, the conflicted blocks will be having markers like `<<<<<<`, `=======`, `>>>>>>>`, and fix it. It may be easy to fix it with some editors too like [VSCode](https://code.visualstudio.com/) if you are using. Or you can use some merge tools. Check [this question](https://stackoverflow.com/q/161813/2873538). – Ajeet Shah May 27 '20 at 22:15
  • 1
    Great, mate! Thanks, @AjeetShah! – Eveline Rojas May 28 '20 at 14:10

1 Answers1

0

The problem is that you might have duplicate keys in your package.json file. To fix it:

1. Open your package.json trace it for duplicate keys. To give you some ease start with the dependencies and devDependencies key.

2. If you find duplicate keys compare and copy and paste the dependencies that are not duplicated into one key and delete the rest.

3. Run npm install

Example: At the start, I had this.

 "dependencies": {
    "@react-navigation/material-bottom-tabs": "^6.1.1",
    "@react-navigation/material-top-tabs": "^6.1.1",
    "@react-navigation/native": "^6.0.8",
    "@react-navigation/native-stack": "^6.5.0",
    "axios": "^0.26.0",
    "eject": "expo eject"
  },
  "dependencies": {
    "expo": "~44.0.0",
    "expo-status-bar": "~1.2.0",
    "react": "17.0.1",
    "react-dom": "17.0.1",
    "react-native": "0.64.3",
    "react-native-pager-view": "5.4.9",
    "react-native-paper": "^4.11.2",
    "react-native-safe-area-context": "3.3.2",
    "react-native-screens": "~3.10.1",
    "react-native-tab-view": "^3.1.1",
    "react-native-vector-icons": "^9.1.0",
    "react-native-web": "0.17.1",
    "react-redux": "^7.2.6",
    "redux": "^4.1.2",
    "redux-thunk": "^2.4.1",
    "twrnc": "^3.0.2"
  },

after I compared and remove duplicate dependencies and one of the keys. I got this:

"dependencies": {
    "@react-navigation/material-bottom-tabs": "^6.1.1",
    "@react-navigation/material-top-tabs": "^6.1.1",
    "@react-navigation/native": "^6.0.8",
    "@react-navigation/native-stack": "^6.5.0",
    "axios": "^0.26.0",
    "expo": "~44.0.0",
    "expo-status-bar": "~1.2.0",
    "react": "17.0.1",
    "react-dom": "17.0.1",
    "react-native": "0.64.3",
    "react-native-pager-view": "5.4.9",
    "react-native-paper": "^4.11.2",
    "react-native-safe-area-context": "3.3.2",
    "react-native-screens": "~3.10.1",
    "react-native-tab-view": "^3.1.1",
    "react-native-vector-icons": "^9.1.0",
    "react-native-web": "0.17.1",
    "react-redux": "^7.2.6",
    "redux": "^4.1.2",
    "redux-thunk": "^2.4.1",
    "twrnc": "^3.0.2"
  },

You can also check your dev dependencies as well. To avoid this problem in the future do not open your package.json file while installing packages.