facebook / metro

🚇 The JavaScript bundler for React Native
https://metrobundler.dev
MIT License
5.18k stars 614 forks source link

Fails to install with yarn with npm >= 7 dependency #656

Closed ethanneff closed 1 year ago

ethanneff commented 3 years ago

Do you want to request a feature or report a bug?

Bug

What is the current behavior?

Fails with yarn install with npm > 7 as a dependency.

example on  master [!] via ⬢ v15.10.0 via 💎 v2.6.6  took 4s 
✦ ❯ yarn 
yarn install v1.22.10
[1/4] 🔍  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] 🔗  Linking dependencies...

error An unexpected error occurred: "could not find a copy of semver to link in /Users/e/Desktop/example/node_modules/metro-react-native-babel-transformer/node_modules/@babel/core/node_modules".
info If you think this is a bug, please open a bug report with the information provided in "/Users/e/Desktop/example/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

If the current behavior is a bug, please provide the steps to reproduce and a minimal repository on GitHub that we can yarn install and yarn test.

add "npm": "7.8.0", as a dependency and run yarn install

What is the expected behavior?

able to run yarn install without error

Please provide your exact Metro configuration and mention your Metro, node, yarn/npm version and operating system.

{
  "dependencies": {
    "@invertase/react-native-apple-authentication": "2.1.1",
    "@mdi/js": "5.9.55",
    "@mdi/react": "1.5.0",
    "@react-native-community/async-storage": "1.12.1",
    "@react-native-community/google-signin": "5.0.0",
    "@react-native-community/masked-view": "0.1.10",
    "@react-native-community/netinfo": "6.0.0",
    "@react-native-community/slider": "3.0.3",
    "@react-native-firebase/analytics": "11.2.0",
    "@react-native-firebase/app": "11.2.0",
    "@react-native-firebase/auth": "11.2.0",
    "@react-native-firebase/crashlytics": "11.2.0",
    "@react-native-firebase/firestore": "11.2.0",
    "@react-native-firebase/remote-config": "11.2.0",
    "@react-navigation/bottom-tabs": "5.11.9",
    "@react-navigation/native": "5.9.4",
    "@react-navigation/stack": "5.14.4",
    "axios": "0.21.1",
    "d3-scale": "3.2.4",
    "d3-shape": "2.1.0",
    "date-fns": "2.19.0",
    "dayjs": "1.10.4",
    "howler": "2.2.1",
+   "npm": "7.8.0",
    "npm-check-updates": "11.3.0",
    "patch-package": "6.4.7",
    "postinstall-postinstall": "2.1.0",
    "react": "17.0.2",
    "react-dom": "17.0.2",
    "react-native": "0.64.0",
    "react-native-apple-authentication": "1.0.8",
    "react-native-config": "1.4.2",
    "react-native-device-info": "8.0.8",
    "react-native-gesture-handler": "1.10.3",
    "react-native-get-random-values": "1.6.0",
    "react-native-keyboard-aware-scroll-view": "0.9.3",
    "react-native-linear-gradient": "2.5.6",
    "react-native-rate": "1.2.4",
    "react-native-reanimated": "2.1.0",
    "react-native-safe-area-context": "3.2.0",
    "react-native-screens": "3.0.0",
    "react-native-sensors": "7.2.0",
    "react-native-sound": "0.11.0",
    "react-native-svg": "12.1.0",
    "react-native-vector-icons": "8.1.0",
    "react-native-web": "0.15.5",
    "react-native-web-linear-gradient": "1.1.1",
    "react-redux": "7.2.3",
    "react-scripts": "4.0.3",
    "recyclerlistview": "3.0.5",
    "redux": "4.0.5",
    "redux-persist": "6.0.0",
    "redux-thunk": "2.3.0",
    "reselect": "4.0.0",
    "typesafe-actions": "5.1.0",
    "utility-types": "3.10.0",
    "uuid": "8.3.2"
  },
  "devDependencies": {
    "@babel/core": "7.13.14",
    "@babel/runtime": "7.13.10",
    "@commitlint/cli": "12.1.1",
    "@commitlint/config-conventional": "12.1.1",
    "@react-native-community/eslint-config": "2.0.0",
    "@semantic-release/changelog": "5.0.1",
    "@semantic-release/commit-analyzer": "8.0.1",
    "@semantic-release/git": "9.0.0",
    "@semantic-release/github": "7.2.1",
    "@semantic-release/npm": "7.1.0",
    "@semantic-release/release-notes-generator": "9.0.2",
    "@types/axios": "0.14.0",
    "@types/d3-scale": "3.2.2",
    "@types/d3-shape": "2.0.0",
    "@types/howler": "2.2.2",
    "@types/jest": "26.0.22",
    "@types/react": "17.0.3",
    "@types/react-native": "0.64.2",
    "@types/react-native-vector-icons": "6.4.6",
    "@types/react-redux": "7.1.16",
    "@types/react-test-renderer": "17.0.1",
    "@types/uuid": "8.3.0",
    "@typescript-eslint/eslint-plugin": "4.21.0",
    "@typescript-eslint/parser": "4.21.0",
    "@welldone-software/why-did-you-render": "6.1.1",
    "babel-plugin-transform-remove-console": "6.9.4",
    "codecov": "3.8.1",
    "eslint-plugin-import": "2.22.1",
    "eslint-plugin-prettier": "3.3.1",
    "husky": "6.0.0",
    "metro-react-native-babel-preset": "0.65.2",
    "prettier": "2.2.1",
    "react-native-bundle-visualizer": "2.2.1",
    "react-native-dev-menu": "4.0.2",
    "react-native-highlight-updates": "1.2.0",
    "react-test-renderer": "17.0.2",
    "semantic-release": "17.4.2",
    "travis-deploy-once": "5.0.11",
    "typescript": "4.2.3"
  }
}
robhogan commented 1 year ago

Sorry we never replied to this - I'm not sure what the use case would be for adding npm as a project dependency, but in any case I just tried it on a fresh RN 70 app and had no issue. Feel free to open a new issue if this is still causing problems.