I have react-native installed through npm in both global as well as local node_modules folder. I will like to try node REPL to walk through some react-native examples step-by-step. When I tried to load react-native module in node, I got the error below:
$ node
> var React=require('react-native');
Error: Cannot find module 'ActivityIndicatorIOS'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/yourname/scripts/code/startup/reactnative/AwesomeProject/node_modules/react-native/Libraries/react-native/react-native.js:22:25)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
>
Looking at the error message above, node found react-native in the local node_modules path, but errored out when executing this in react-native.js:
var ReactNative = Object.assign(Object.create(require('React')), {
// Components
ActivityIndicatorIOS: require('ActivityIndicatorIOS'),
DatePickerIOS: require('DatePickerIOS'),
Image: require('Image'),
May be this has something to do with ActivityIndicatorIOS being a native UI component in Xcode project, which may not mesh well with REPL?
My knowledge of node.js and require is very basic. So, help fixing this error will be very much appreciated.
Aucun commentaire:
Enregistrer un commentaire