1

I’m trying to install the npm module wallet-address-validator in a React Native application. I am using expo for my development environment.

First I install wallet-address-validator

npm install wallet-address-validator

Then I run

expo start

And I get these errors

Expo Developer Tools is disconnected from Expo CLI. Use the expo start command to start the CLI again.

[14:23:00] Opening DevTools in the browser... (press shift-d to disable)

[14:23:02] Error: React native is not installed. Please run npm install in your project directory.

[14:23:02] Couldn't start project. Please fix the errors and restart the project.

[14:23:02] Set EXPO_DEBUG=true in your env to view the stack trace.

So I ran

npm install

Then I ran

expo start again

and I get this error

14:26

Recrawled this watch 1 times, most recently because: /home/dale/Desktop/Rails/TestApps/testApp: dir missing from internal state To resolve, please review the information on https://facebook.github.io/watchman/docs/troubleshooting.html#recrawl To clear this warning, run: watchman watch-del /home/dale/Desktop/Rails/TestApps/testApp ; watchman watch-project /home/dale/Desktop/Rails/TestApps/testApp

1 Answer 1

1

1) yarn add wallet-address-validator 2) npm install -g browserify 3) Create a file wav-in.js that imports the wallet-address-validator module and simply exports it:

var WAValidator = require('wallet-address-validator'); module.exports = WAValidator; 

4) Then in the terminal in the project

browserify cwav-in.js -o wav.js 

5) This will result in an error if you put in the test code below from Wallet-Address-validator in App.js

var WAValidator = require('wallet-address-validator');

var valid = WAValidator.validate('1KFzzGtDdnq5hrwxXGjwVnKzRbvf8WVxck', 'BTC'); if(valid) console.log('This is a valid address'); else console.log('Address INVALID');

6) You will however, get an error along the lines “… is not a function”

7) On line 3837 of wav.js change “var WAValidator = require('wallet-address-validator');” to “WAValidator = require('wallet-address-validator');”

8) On the very last line in of wav.js add “module.exports = WAValidator;”

everything should be working now

This article is also on point https://hackernoon.com/using-core-node-js-modules-in-react-native-apps-64acd4d07140

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.