frostney / react-native-create-library

:notebook: Command line tool to create a React Native library with a single command
MIT License
1.45k stars 113 forks source link

error: bundling failed: ambiguous resolution: module .../index.js tries to require react-native, but there are several files providing this module. You can delete or fix them #89

Closed jerinho closed 5 years ago

jerinho commented 5 years ago

i had follow the installation instruction properly

  1. uninstall default package. npm remove react-native-create-library
  2. install new package from here. npm i -g git+https://github.com/frostney/react-native-create-library.git

C:\Users\USER\AppData\Roaming\npm\react-native-create-library -> C:\Users\USER\AppData\Roaming\npm\node_modules\react-native-create-library\cli.js +react-native-create-library@3.1.2 added 91 packages from 39 contributors in 82.13s

  1. react-native-create-library mylib

While RN is the default prefix, it is recommended to customize the prefix. While {DEFAULT_PACKAGE_IDENTIFIER} is the default package identifier, it is recommended to customize the package identifier. 📚 Created library testlib in ./testlib. 🕘 It took 112ms. ➡️ To get started type cd ./testlib and run npm install

  1. testlib directory not exists. the name is react-native-testlib. so i do cd ./react-native-testlib instead. followed by yarn

yarn install v1.9.4 info No lockfile found. [1/4] Resolving packages... warning react-native > connect@2.30.2: connect 2.x series is deprecated info There appears to be trouble with your network connection. Retrying... warning react-native-windows > yeoman-generator > cross-spawn > cross-spawn-async@2.2.5: cross-spawn no longer requires a build toolchain, use it instead warning react-native-windows > yeoman-generator > download > gulp-decompress > gulp-util@3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5 warning react-native-windows > yeoman-generator > sinon > formatio@1.1.1: This package is unmaintained. Use @sinonjs/formatio instead [2/4] Fetching packages... info fsevents@1.2.4: The platform "win32" is incompatible with this module. info "fsevents@1.2.4" is an optional dependency and failed compatibility check. Excluding it from installation. [3/4] Linking dependencies... [4/4] Building fresh packages... success Saved lockfile. Done in 307.98s.

  1. yarn link

yarn link v1.9.4 success Registered "react-native-testlib". info You can now run yarn link "react-native-testlib" in the projects where you want to use this package and it will be used instead. Done in 0.12s.

  1. yarn link react-native-testlib on project directory

yarn link v1.9.4 success Using linked package for "react-native-testlib". Done in 0.15s.

  1. react-native link react-native-testlib. expected automatic installation works perfectly as manual installation. but it's not. so i have to do it manually

  2. react-native run-android working as expected for android part. but metro bundler show compilation error

error: bundling failed: ambiguous resolution: module C:\Users\USER\Desktop\test\index.js tries to require react-native, but there are several files providing this module. You can delete or fix them: C:\Users\USER\AppData\Local\Yarn\Data\link\react-native-testlib\node_modules\react-native\package.json C:\Users\USER\Desktop\test\node_modules\react-native\package.json

maicki commented 5 years ago

@jerinho Unfortunately you cannot symlink a react native package. This is a problem with the metro bundler and you can follow the issue here: https://github.com/facebook/metro/issues/1

jerinho commented 5 years ago

@jerinho Unfortunately you cannot symlink a react native package. This is a problem with the metro bundler and you can follow the issue here: facebook/metro#1

thank you. but then yarn should not loads packages into node_modules directory. just like how the default "outdated" react-native-create-library works. please kindly let me know if anybody get different result