can't find '@react-navigation/stack' module in ReactNative Project

Viewed 483

I changed my npm global root and it's such a mess .. now this is my npm list,, and I have react-navigation in it but it doesn't work.

npm list
npm WARN read-shrinkwrap This version of npm is compatible with lockfileVersion@1, but package-lock.json was generated for lockfileVersion@2. I'll try to do my best with it!
C:\Users\20wjs
+-- UNMET DEPENDENCY @babel/preset-env@7.16.11
+-- @react-navigation/native@6.0.8
| +-- @react-navigation/core@6.1.1
| | +-- @react-navigation/routers@6.1.0       
| | | `-- nanoid@3.3.1 deduped
| | +-- escape-string-regexp@4.0.0 deduped    
| | +-- nanoid@3.3.1 deduped
| | +-- query-string@7.1.1
| | | +-- decode-uri-component@0.2.0
| | | +-- filter-obj@1.1.0
| | | +-- split-on-first@1.1.0
| | | `-- strict-uri-encode@2.0.0
| | `-- react-is@16.13.1
| +-- escape-string-regexp@4.0.0
| +-- fast-deep-equal@3.1.3
| `-- nanoid@3.3.1
+-- @react-navigation/stack@6.1.1
| +-- @react-navigation/elements@1.3.1
| +-- color@3.2.1
| | +-- color-convert@1.9.3
| | | `-- color-name@1.1.3
| | `-- color-string@1.9.0
| |   +-- color-name@1.1.3 deduped
| |   `-- simple-swizzle@0.2.2
| |     `-- is-arrayish@0.3.2
| `-- warn-once@0.1.0
+-- @types/react@17.0.41
| +-- @types/prop-types@15.7.4
| +-- @types/scheduler@0.16.2
| `-- csstype@3.0.11
+-- @types/react-dom@17.0.14
| `-- @types/react@17.0.41 deduped
+-- @types/react-native@0.67.3
| `-- @types/react@17.0.41 deduped
+-- @types/styled-components@5.1.24
| +-- @types/hoist-non-react-statics@3.3.1
| | +-- @types/react@17.0.41 deduped
| | `-- hoist-non-react-statics@3.3.2 deduped
| +-- @types/react@17.0.41 deduped
| `-- csstype@3.0.11 deduped
+-- @types/styled-components-react-native@5.1.3
| +-- @types/react@17.0.41 deduped
| +-- @types/react-native@0.65.21
| | `-- @types/react@17.0.41 deduped
| `-- @types/styled-components@5.1.24 deduped
+-- UNMET DEPENDENCY react@17.0.2
+-- UNMET DEPENDENCY react-native@0.67.4
+-- UNMET DEPENDENCY react-native-gesture-handler@2.3.2
| +-- @egjs/hammerjs@2.0.17
| | `-- @types/hammerjs@2.0.41
| +-- hoist-non-react-statics@3.3.2
| | `-- react-is@16.13.1 deduped
| +-- UNMET DEPENDENCY invariant@2.2.4
| | `-- UNMET DEPENDENCY loose-envify@1.4.0
| |   `-- UNMET DEPENDENCY js-tokens@4.0.0
| +-- lodash@4.17.21
| `-- UNMET DEPENDENCY prop-types@15.8.1
|   +-- UNMET DEPENDENCY loose-envify@1.4.0
|   +-- object-assign@4.1.1
|   `-- react-is@16.13.1 deduped
+-- react-native-paper@4.11.2
| +-- @callstack/react-theme-provider@3.0.7
| | +-- deepmerge@3.3.0
| | `-- hoist-non-react-statics@3.3.2 deduped
| +-- color@3.2.1 deduped
| `-- react-native-iphone-x-helper@1.3.1
+-- UNMET DEPENDENCY react-native-reanimated@2.4.1
| +-- @babel/plugin-transform-object-assign@7.16.7
| | `-- @babel/helper-plugin-utils@7.16.7
| +-- @types/invariant@2.2.35
| +-- UNMET DEPENDENCY invariant@2.2.4
| +-- lodash.isequal@4.5.0
| +-- mockdate@3.0.5
| +-- react-native-screens@3.13.1 deduped
| `-- string-hash-64@1.0.3
+-- react-native-safe-area-context@4.2.1 extraneous
+-- react-native-screens@3.13.1
| +-- react-freeze@1.0.0
| `-- warn-once@0.1.0 deduped
+-- UNMET DEPENDENCY react-native-vector-icons@9.1.0
+-- react-navigation@4.4.4
| +-- @react-navigation/core@3.7.9
| | +-- hoist-non-react-statics@3.3.2 deduped
| | +-- path-to-regexp@1.8.0
| | | `-- isarray@0.0.1
| | +-- query-string@6.14.1
| | | +-- decode-uri-component@0.2.0 deduped
| | | +-- filter-obj@1.1.0 deduped
| | | +-- split-on-first@1.1.0 deduped
| | | `-- strict-uri-encode@2.0.0 deduped
| | `-- react-is@16.13.1 deduped
| `-- @react-navigation/native@3.8.4
|   +-- hoist-non-react-statics@3.3.2 deduped
|   `-- react-native-safe-area-view@0.14.9
|     `-- hoist-non-react-statics@2.5.5
+-- typescript@4.6.2
`-- valid-url@1.0.9

npm ERR! missing: @babel/preset-env@7.16.11, required by 20wjs
npm ERR! missing: react@17.0.2, required by 20wjs
npm ERR! missing: react-native@0.67.4, required by 20wjs
npm ERR! missing: react-native-vector-icons@9.1.0, required by 20wjs
npm ERR! missing: react-native-gesture-handler@2.3.2, required by 20wjs
npm ERR! missing: react-native-reanimated@2.4.1, required by 20wjs
npm ERR! extraneous: @babel/preset-env@7.16.11 C:\Users\20wjs\node_modules\@babel\preset-env
npm ERR! extraneous: react@17.0.2 C:\Users\20wjs\node_modules\react
npm ERR! extraneous: react-native@0.67.4 C:\Users\20wjs\node_modules\react-native
npm ERR! extraneous: react-native-safe-area-context@4.2.1 C:\Users\20wjs\node_modules\react-native-safe-area-context      
npm ERR! extraneous: react-native-vector-icons@9.1.0 C:\Users\20wjs\node_modules\react-native-vector-icons
npm ERR! missing: invariant@2.2.4, required by react-native-gesture-handler@2.3.2
npm ERR! missing: prop-types@15.8.1, required by react-native-gesture-handler@2.3.2
npm ERR! missing: loose-envify@1.4.0, required by invariant@2.2.4
npm ERR! missing: js-tokens@4.0.0, required by loose-envify@1.4.0
npm ERR! missing: loose-envify@1.4.0, required by prop-types@15.8.1
npm ERR! missing: invariant@2.2.4, required by react-native-reanimated@2.4.1

And this is my package.json

{
  "name": "healthreactnative",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "android": "react-native run-android",
    "ios": "react-native run-ios",
    "start": "react-native start",
    "test": "jest",
    "lint": "eslint ."
  },
  "dependencies": {
    "react": "17.0.2",
    "react-native": "0.67.2"
  },
  "devDependencies": {
    "@babel/core": "^7.17.5",
    "@babel/runtime": "^7.17.2",
    "@react-native-community/eslint-config": "^3.0.1",
    "babel-jest": "^27.5.1",
    "eslint": "^8.9.0",
    "jest": "^27.5.1",
    "metro-react-native-babel-preset": "^0.68.0",
    "react-test-renderer": "17.0.2"
  },
  "jest": {
    "preset": "react-native"
  },
  "rnpm": {
    "assets": ["./src/main/assets/fonts"]
  }
}


Can anyone help me..?? Do I lost some modules in node_modules? How can I handle this?? Can you give me some tips how to see this error? How can I install some missing things??

2 Answers

If you run npm install, it tries to pick up the dependencies to install from your package.json. But the problem is @react-navigation/stack is not there.

You need to install that dependency in order to use it. Thus try to install that module like the following:

npm install @react-navigation/stack

You need to install @react-navigation/stack and react-native-gesture-handler, again, as per your package.json file, these are missing there. Moreover, i can see other modules missing from your package.json, Simply install them and they will add up to your package.json dependencies. This might solve your issues of missing modules. Ill recommend, dont delete your node_modules folder right away, take notes/list of modules required by your project and npm install them.

Related