React-native: [fatal][tid:main] Unable to resolve module react

Created on 12 Jul 2016  ·  12Comments  ·  Source: facebook/react-native

I run xcode project prompted the following error:

[tid:main] Unable to resolve module react from /Users/chenchen/Documents/project/mywebsite/index.ios.js: Unable to find this module in its module map or any of the node_modules directories under /Users/node_modules/react and its parent directories

Do the checklist before filing an issue:

This might be related to https://github.com/facebook/react-native/issues/4968
To resolve try the following:

  1. Clear watchman watches: watchman watch-del-all.
  2. Delete the node_modules folder: rm -rf node_modules && npm install.
  3. Reset packager cache: rm -fr $TMPDIR/react-* or npm start -- --reset-cache.

I follow the above instructions, but still valid

Locked

Most helpful comment

@XiaoLiz
you not install react

npm i --save react

不谢!

All 12 comments

@XiaoLiz I think this could be a problem with PATH+npm on windows.
Please try the following:
reinstall all to latest:

npm: 3.10.3
node: 6.3.0
react-native: ^0.29.0
react: 15.2.1

Then:

rm -rf node_modules 
npm clean cache
watchman watch-del-all
npm i
npm start -- --reset-cache

@stoffern The need to install npm install react ?

@XiaoLiz Yes, react-native uses react framework to get its structure.

import React, {Component} from 'react'

@stoffern According to the above process still not been resolved

@XiaoLiz can you post your index.ios.js code?

@stoffern

This is init project index.ios.js

/**

import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';

class mywebsite extends Component {
render() {
return (
Welcome to React Native!

To get started, edit index.ios.js

Press Cmd+R to reload,{'\n'}
Cmd+D or shake for dev menu


);
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});

AppRegistry.registerComponent('mywebsite', () => mywebsite);

@XiaoLiz no problems there.
is your project located here: /Users/chenchen/Documents/project/mywebsite ?

what happends if you run:
./node_modules/react-native/packager/packager.sh start --reset-cache

@stoffern

Yes ! my project located here: /Users/chenchen/Documents/project/mywebsite

my run:

./node_modules/react-native/packager/packager.sh start --reset-cache

image

@XiaoLiz is your package.json and your node_modules folder inside: /Users/chenchen/Documents/project/mywebsite ?

@stoffern

Yes !

@XiaoLiz
you not install react

npm i --save react

不谢!

Looks like this has been solved.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

cpojer picture cpojer  ·  196Comments

alinz picture alinz  ·  138Comments

rkostrab picture rkostrab  ·  139Comments

abumostafa picture abumostafa  ·  263Comments

joncursi picture joncursi  ·  134Comments