React native package-lock.json duplicate dependencies/packages

Viewed 559

Whenever I run npm i in my project base directory, the package-lock file is doubled in size. This seems to be happening because there is a "packages" part in the package-lock, which contains all project dependencies stated as "node_modules/somePackageName", but after all 10,000 of these lines there is a "dependencies" part which essentially has all of the same things but without the node_modules prefix part. Whenever anyone in my group runs npm i, nothing new is added but when I run it the 10,000 lines with node_modules/... are added.

I have tried deleting node_modules as well as the package lock, and then doing npm i again, but the same result happens. I understand the functionality of package-lock, but I don't know why it is adding everything twice with a different path.

Here is my package.json:

    {
  "main": "node_modules/expo/AppEntry.js",
  "scripts": {
    "start": "expo start",
    "android": "expo start --android",
    "ios": "expo start --ios --simulator=\"iPhone 11 Pro Max\"",
    "web": "expo start --web",
    "eject": "expo eject",
    "lint": "eslint --ext .js,.jsx ./components --quiet",
    "lint-autofix": "eslint --ext .js,.jsx ./components --quiet --fix"
  },
  "dependencies": {
    "@expo-google-fonts/montserrat": "^0.1.0",
    "@expo/vector-icons": "^10.2.1",
    "@react-navigation/bottom-tabs": "^5.9.2",
    "@react-navigation/native": "^5.7.6",
    "expo": "^39.0.3",
    "expo-font": "~8.3.0",
    "expo-status-bar": "~1.0.2",
    "firebase": "7.9.0",
    "prop-types": "^15.7.2",
    "react": "16.13.1",
    "react-dom": "16.13.1",
    "react-native": "https://github.com/expo/react-native/archive/sdk-39.0.3.tar.gz",
    "react-native-gesture-handler": "~1.7.0",
    "react-native-paper": "^4.2.0",
    "react-native-reanimated": "^1.13.1",
    "react-native-screens": "~2.10.1",
    "react-native-vector-icons": "^7.1.0",
    "react-native-web": "~0.13.12",
    "react-navigation-stack": "^2.10.1",
    "styled-components": "^5.2.0"
  },
  "devDependencies": {
    "@babel/core": "~7.9.0",
    "eslint": "^7.11.0",
    "eslint-config-airbnb": "^18.2.0",
    "eslint-plugin-import": "^2.22.1",
    "eslint-plugin-jsx-a11y": "^6.3.1",
    "eslint-plugin-react": "^7.21.4",
    "eslint-plugin-react-hooks": "^4.1.2"
  },
  "private": true
}
1 Answers

For anyone still facing this, I fixed this by downgrading my npm version to 6.14.5. (I was on 7 earlier)

Related