Posts

Showing posts with the label React-native

Resolve error :"Unable to resolve module `crypto` in \\azure-mobile-apps-client\\node_modules\\node-uuid\\uuid.js''

I met issue "Unable to resolve module `crypto` in \\azure-mobile-apps-client\\node_modules\\node-uuid\\uuid.js'" when I developed an App using React Native and Azure Mobile App Service. The Azure Mobile App Service uses the crypto module in "uuid.js" such as "require('crypto').randomBytes", because crypto is a core Node JS module, and the React Native packager can’t package it along with app’s Javascript bundle, so it throws a runtime error: Unable to resolve module 'crypto'. I did a research on google.com, and fount out this article " Using Core Node JS Modules in React Native Apps ". Based on this article, I came out a solution to resolve this problem as below. npm install -g browserify  Create a file  crypto-in.js  that imports the  crypto  module and simply exports it:  var crypto=require("crypto"); module.exports=crypto;  Create a standalone Javascript bundle   crypto.js  using  browserify in NPM ...

React Native: buffer is not defined

Image
I tried to use "azure-mobile-apps-client" npm package in a React Native app, and it throws error "buffer is not defined" in Simulator. I searched around in google.com, and found out below solution: global.Buffer = global.Buffer || require('buffer').Buffer; var WindowsAzure=require('azure-mobile-apps-client'); I added above code to the .js file, and run it again. Done! the issue is gone and I can get the Azure Mobile App Service Client object which can be seen in the debug code in Chrome.     Run "npm i", and then run the app successfully. :) Further Study     I had been studied the online course " The Complete React Native and Redux Course ", it gave me the clear explanation and instruction with step by step procedures to learn the core knowledge to build React components for mobile devices. It's suitable for all levels. The course has sample code and completed projects in gitHub.com. Instructor : St...

React Native error - Cannot find module 'metro-react-native-babel-preset'

Image
I created a React native app using "react-native init <App Name> " but received below error when try to run it in Simulator: Cannot find module 'metro-react-native-babel-preset' I resolved the error by adding below line under "dependencies" in package.json.     "@babel/runtime": "^7.0.0-beta.55"  Run "npm i", and then run the app successfully. :) Further Study     I had been studied the online course " The Complete React Native and Redux Course ", it gave me the clear explanation and instruction with step by step procedures to learn the core knowledge to build React components for mobile devices. It's suitable for all levels. The course has sample code and completed projects in gitHub.com. Instructor : Stephen Grider -  Engineering Architect, Stephen Grider has been building complex Javascript front ends for top corporations in the San Francisco Bay Area.