Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicate module name: react-native #139

Closed
vkandk opened this issue Dec 13, 2018 · 17 comments
Closed

Duplicate module name: react-native #139

vkandk opened this issue Dec 13, 2018 · 17 comments

Comments

@vkandk
Copy link

vkandk commented Dec 13, 2018

ERROR:
Duplicate module name: react-native
Paths: ..<project-name>\node_modules\react-native-razorpay\node_modules\react-native\package.json
collides with
..<project-name>\node_modules\react-native\package.json
This error is caused by a @providesModule declaration with the same name across two different files.

Application details ->

React Native AWS Mobile Hub App -
package.json:
{...
"react": "16.5.0",
"react-native": " 0.57.1",
"react-native-razorpay": "^2.0.16",
...
}

build.gradle:
buildscript {
repositories {
google()
jcenter()
gradlePluginPortal()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

}

allprojects {
repositories {
mavenLocal()
jcenter()
maven { url "https://jitpack.io" }
maven { url "https://maven.google.com" }
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
}

android/app/build.gradle:

android {
compileSdkVersion 27
buildToolsVersion "28.0.3"
defaultConfig {
applicationId ""
minSdkVersion 19
targetSdkVersion 27
versionCode 29
versionName ""
vectorDrawables.useSupportLibrary = true
}

dependencies {
implementation project(':react-native-view-pdf')
implementation project(':react-native-svg')
implementation project(':react-native-image-crop-picker')
implementation project(':amazon-cognito-identity-js')
implementation project(':react-native-fetch-blob')
implementation project(':react-native-vector-icons')
implementation project(':react-native-razorpay')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:25.0.0"
implementation "com.facebook.react:react-native:+" // From node_modules
}

@iThink32
Copy link
Contributor

@vkandk the ideal solution is blacklisting the node modules folder in react-native-razorpay.But even if you remove node modules it will work.

@jfreak
Copy link

jfreak commented Dec 19, 2018

Tried blacklisting the node modules folder in react-native-razorpay still having the same issue

 "react": "16.6.1",
 "react-native": "0.57.7"

@iThink32
Copy link
Contributor

@jfreak delete your derived data , close your metro bundler , clean and build.
If all fails you can delete the node modules folder in react-native-razorpay and try.

@GaudamThiyagarajan
Copy link

create rn-cli.config.js in your root folder and blacklist the node_modules from react-native-razorpay.

const blacklist = require('metro/src/blacklist');

module.exports = {
  // getTransformModulePath() {
  //   return require.resolve('./customTransformer');
  // },
  getBlacklistRE() {
    return blacklist([
      /node_modules\/react-native-razorpay\/node_modules\/.*/,
    ]);
  },
};

@jfreak
Copy link

jfreak commented Dec 20, 2018

create rn-cli.config.js in your root folder and blacklist the node_modules from react-native-razorpay.

const blacklist = require('metro/src/blacklist');

module.exports = {
  // getTransformModulePath() {
  //   return require.resolve('./customTransformer');
  // },
  getBlacklistRE() {
    return blacklist([
      /node_modules\/react-native-razorpay\/node_modules\/.*/,
    ]);
  },
};

react-native run-android --config rn-cli.config.js
(node:14361) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, open '/Volumes/MacHD/Cumint/Apps/Test/node_modules/react-native/local-cli/core/rn-cli.config.js'
(node:14361) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:14361) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@jfreak
Copy link

jfreak commented Dec 20, 2018

@jfreak delete your derived data , close your metro bundler , clean and build.
If all fails you can delete the node modules folder in react-native-razorpay and try.

Stopped and cleared all temp files of metro bundler still facing the same issues.
Deleting node modules folder is solution for now but not a permanent one.

@iThink32
Copy link
Contributor

iThink32 commented Dec 21, 2018

@jfreak there are two permanent solutions for this :

  • blacklisting which is working for a lot of people including me , you have to figure out why it isn't working for you.
  • move the dependencies in the package.json of react-native-razorpay to devDependencies (yet to try out but according to my research it is the cause of this issue).Have a look at this link

https://stackoverflow.com/questions/18875674/whats-the-difference-between-dependencies-devdependencies-and-peerdependencies

@perminder-klair
Copy link

having same issue guys! hope it will be resolved soon.

@iThink32
Copy link
Contributor

@perminder-klair the solution is posted above , please follow it.

@direwolf424
Copy link

@jfreak Did you get any solution as i am also getting the same error.

@iThink32 Do we need to pass the config file like this
react-native run-android --config rn-cli.config.js

@GaudamThiyagarajan
Copy link

You don't have to pass the config file. It takes by default if you place it in the root folder. check here

@iThink32
Copy link
Contributor

@direwolf424 have a look at the example folder in this repo , it'll help you out.Ive used blacklisting there.

@jfreak
Copy link

jfreak commented Jan 3, 2019

Sorry for the late reply @iThink32 the solution works as of now
@direwolf424
My rn-cli.config.js file

const blacklist = require('metro-config/src/defaults/blacklist')

module.exports = {
  resolver: {
    blacklistRE: blacklist([/node_modules\/react-native-razorpay\/node_modules\/.*/])
  }
};

Just run react-native run android normally
For more information check out the example in the repo

@iThink32
Copy link
Contributor

iThink32 commented Jan 3, 2019

@jfreak cool.

@iThink32
Copy link
Contributor

iThink32 commented Jan 3, 2019

closing this issue.Reopen if required.

@iThink32 iThink32 closed this as completed Jan 3, 2019
@itsarvindh
Copy link

Blacklisting node_modules in react-native-razorpay wouldn't create prob while in production ? As blacklisting solves the duplicate module name problem. But what about in production is it safe to do that ? Can i use this method to continue or is there any other good solution ?

@iThink32
Copy link
Contributor

@itsarvindh blacklisting helps in avoiding files being compiled to ultimately create an executable , it has no effect after an executable has been created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants