react-native-navigation icon indicating copy to clipboard operation
react-native-navigation copied to clipboard

Error when using v2.0

Open huythoawedding opened this issue 8 years ago • 9 comments

My dependencies: { "react": "16.2.0", "react-native": "0.53.0", "react-native-navigation": "^2.0.2121" },

error: bundling failed: Error: While trying to resolve module react-native-navigation from file /Users/hihihahahehe/Desktop/GlennDoman/App.js, the package /Users/hihihahahehe/Desktop/GlennDoman/node_modules/react-native-navigation/package.json was successfully found. However, this package itself specifies a main module field that could not be resolved (/Users/hihihahahehe/Desktop/GlennDoman/node_modules/react-native-navigation/lib/dist/index.js. Indeed, none of these files exist:

huythoawedding avatar Feb 09 '18 12:02 huythoawedding

How do you import RNN in your app? It used to be import Navigation from 'react-native-navigation' but nowadays it's import { Navigation } from 'react-native-navigation'

billyohgren avatar Feb 09 '18 13:02 billyohgren

aw, i'm following Usage in Documents: import Navigation from 'react-native-navigation';

Let's i try again

huythoawedding avatar Feb 09 '18 13:02 huythoawedding

@billyohgren i'm still got this error :"(

huythoawedding avatar Feb 09 '18 13:02 huythoawedding

Then try this (in the terminal):

1.npm install -g typescript

  1. then go to the directory of your app
  2. cd node_modules/react-native-navigation
  3. type "tsc" (without "")
  4. run app as usual

That should do it?

billyohgren avatar Feb 09 '18 13:02 billyohgren

@billyohgren Thank you it is so useful 👍

huythoawedding avatar Feb 09 '18 13:02 huythoawedding

Glad I could help! I made a quick update to the documentation as well https://github.com/wix/react-native-navigation/pull/2691

billyohgren avatar Feb 09 '18 14:02 billyohgren

I am new to React and React Native, but getting the same error as above.

Obviously I'm missing some dependency or something - but what? And how do I fix it?

When I run the tsc command from the node_modules/reative-native-navigation folder it get hundreds of errors starting with:

error TS2688: Cannot find type definition file for 'jest'.

error TS2688: Cannot find type definition file for 'lodash'.

error TS2688: Cannot find type definition file for 'react'.

error TS2688: Cannot find type definition file for 'react-native'.

error TS2688: Cannot find type definition file for 'react-test-renderer'.

lib/src/adapters/Element.tsx:20:28 - error TS2339: Property 'props' does not exist on type 'Element'.

20       <RNNElement {...this.props} />
                              ~~~~~

kgomara avatar Nov 27 '18 16:11 kgomara

Hi @kgomara and everyone,

What worked for me was this:

  1. npm uninstall react-native-navigation
  2. npm install -g typescript
  3. npm install --save react-native-navigation

It is important to mention that react-native-navigation is written in typescript and the npm run build form the react-native-navigation directory executes s a tsc command which is from typescript. For some reason if i had react-native-navigation already installed, and then installed the typescript module, and then exceuted npm run build, i got lots of errors. Running this command should generate a dist folder inside lib.

But, when i installed react-native-navigation after the typescript module was installed, it was installed perfectly and even the dist folder was already generated during the installation, so i didn't even have to go there and run npm run build.

edgarbonillag avatar Feb 21 '19 06:02 edgarbonillag

Hi @edgarbonillag it still doesn't work

InuriIlangakoon avatar Sep 10 '19 11:09 InuriIlangakoon