2

I am new to react native trying to use @providesModule but no success the following is my code colors.js

/** 
* @providesModule Colors
*/
const colors = {
   colorPrimary : '#6a1b9a',
   colorPrimaryLight: '#9c4dcc',
  };
 export default colors;

I am trying to use the Colors Module in login.js file like

import Colors from 'Colors'

Error

error: bundling failed: Error: Unable to resolve module Colors from /Volumes/Acube Data/Anns/Projects/ReactNativeProjects/ColDot/src/components/UserAuth/Login.js: Module Colors does not exist in the Haste module map

2
  • Have you configured the babel and installed all the necessary dependencies? Jul 11, 2018 at 7:28
  • Noi didnt configure babel can u please let me know the dependencies for that
    – Anns Rahim
    Jul 11, 2018 at 8:47

2 Answers 2

0

Babel-Cli :

npm install --g babel-cli

babel-plugin-module-alias:

npm install --save babel babel-plugin-module-alias

.babelrc in root directory:

"babel":{
  "plugins": [[
    "module-alias", [
      { "src": "./app", "expose": "app" },
      { "src": "./app/resources/icon", "expose": "icon" }
      ]
   ]]

}

Clear cache :

npm start -- --reset-cache

Here is a link you can check for example of that : alias in react native

0

They don't work because provideModule overall has been removed as a functionality. Removed last traces of @providesModule from React Native

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.