Quantcast
Channel: Active questions tagged react-native+ios - Stack Overflow
Viewing all articles
Browse latest Browse all 16552

Create react native module and use it in application

$
0
0

I want to create react-native module for iOS and Android and use it in an application.

I want to use it like a local module, not uploaded to npm.

When i follow the steps described in the official documentation i always have those error on the import of my module into App.js file :

import MyModule from 'react-test-module';

Could not find a declaration file for module 'react-test-module'. '/Users/dbellerose/Path/to/My/Module/react-test-module/index.js' implicitly has an 'any' type. Try npm install @types/react-test-modulet if it exists or add a new declaration (.d.ts) file containing `declare module 'react-test-module';

When i run the iOS application :

Unable to resolve module react-test-module from /Users/Path/To/My/App/App.js: Module react-test-module does not exist in the Haste module map.

The message give me some tips to solve the problem, but it does not work.

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 Metro Bundler cache: rm -rf /tmp/metro-bundler-cache-* or npm start -- --reset-cache. 4. Remove haste cache: rm -rf /tmp/haste-map-react-native-packager-*.

So what do you know what is the good process to create a module and use it in application without uploading the package to npm ?

Best regards,

David


Viewing all articles
Browse latest Browse all 16552

Trending Articles