react-native-snap-carousel icon indicating copy to clipboard operation
react-native-snap-carousel copied to clipboard

Cannot run example on android: Unable to resolve module `react-native-snap-carousel`

Open kopax opened this issue 4 years ago • 12 comments

Is this a bug report, a feature request, or a question?

Question

Have you followed the required steps before opening a bug report?

Have you made sure that it wasn't a React Native bug?

yes

Is the bug specific to iOS or Android? Or can it be reproduced on both platforms?

Android

Is the bug reproductible in a production environment (not a debug one)?

In an emulator, I didn't went that far to tell it's production

Environment

Emulator

Expected Behavior

I expect to run the examples on android

Actual Behavior

Right after cloning the master branch, running npm run android produce the following

dka@dka:[~/workspace/github.com/archriss/react-native-snap-carousel/example (master)]: npm run start

> [email protected] start /home/dka/workspace/github.com/archriss/react-native-snap-carousel/example
> react-native start

┌──────────────────────────────────────────────────────────────────────────────┐
│                                                                              │
│  Running Metro Bundler on port 8081.                                         │
│                                                                              │
│  Keep Metro running while developing on any JS projects. Feel free to        │
│  close this tab and run your own Metro instance if you prefer.               │
│                                                                              │
│  https://github.com/facebook/react-native                                    │
│                                                                              │
└──────────────────────────────────────────────────────────────────────────────┘

Looking for JS files in
   /home/dka/workspace/github.com/archriss/react-native-snap-carousel/example 

Loading dependency graph, done.

To reload the app press "r"
To open developer menu press "d"

info Reloading app...
error: bundling failed: Error: Unable to resolve module `react-native-snap-carousel` from `src/index.js`: react-native-snap-carousel could not be found within the project.

If you are sure the module exists, try these steps:
 1. Clear watchman watches: watchman watch-del-all
 2. Delete node_modules: rm -rf node_modules and run yarn install
 3. Reset Metro's cache: yarn start --reset-cache
 4. Remove the cache: rm -rf /tmp/metro-*
    at ModuleResolver.resolveDependency (/home/dka/workspace/github.com/archriss/react-native-snap-carousel/example/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:186:15)
    at ResolutionRequest.resolveDependency (/home/dka/workspace/github.com/archriss/react-native-snap-carousel/example/node_modules/metro/src/node-haste/DependencyGraph/ResolutionRequest.js:52:18)
    at DependencyGraph.resolveDependency (/home/dka/workspace/github.com/archriss/react-native-snap-carousel/example/node_modules/metro/src/node-haste/DependencyGraph.js:282:16)
    at Object.resolve (/home/dka/workspace/github.com/archriss/react-native-snap-carousel/example/node_modules/metro/src/lib/transformHelpers.js:267:42)
    at /home/dka/workspace/github.com/archriss/react-native-snap-carousel/example/node_modules/metro/src/DeltaBundler/traverseDependencies.js:426:31
    at Array.map (<anonymous>)
    at resolveDependencies (/home/dka/workspace/github.com/archriss/react-native-snap-carousel/example/node_modules/metro/src/DeltaBundler/traverseDependencies.js:423:18)
    at /home/dka/workspace/github.com/archriss/react-native-snap-carousel/example/node_modules/metro/src/DeltaBundler/traverseDependencies.js:275:33
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/home/dka/workspace/github.com/archriss/react-native-snap-carousel/example/node_modules/metro/src/DeltaBundler/traverseDependencies.js:87:24)
 BUNDLE  [android, dev] ./index.js ▓▓░░░░░░░░░░░░░░ 16.0% (2/94)::ffff:127.0.0.1 - - [07/Apr/2020:17:23:51 +0000] "GET /index.bundle?platform=android&dev=true&minify=false HTTP/1.1" 500 - "-" "okhttp/3.12.1"
 BUNDLE  [android, dev] ./index.js ▓▓░░░░░░░░░░░░░░ 16.0% (2/94), failed.

image

Reproducible Demo

The examples directory of this repository

Steps to Reproduce

git clone https://github.com/archriss/react-native-snap-carousel.git
cd react-native-snap-carousel
npm i
cd example
npm i
npm run start
# press r

kopax avatar Apr 07 '20 17:04 kopax

add react-native-snap-carousel

superqianqian avatar Apr 26 '20 08:04 superqianqian

It seems to work with yarn instead of npm (I can reproduce the issue with npm). Don't know the reason yet

git clone https://github.com/archriss/react-native-snap-carousel.git
cd react-native-snap-carousel
yarn
cd example
yarn
yarn android

I tried to change the example's package.json on "react-native-snap-carousel": "file:../" to "react-native-snap-carousel": "3.9.0" in this cae, it can work with npm install and npm run android. So I think it might relate to the local package and npm.

gie3d avatar May 02 '20 10:05 gie3d

any solution with npm yet?

prashantbasnet94 avatar May 06 '21 23:05 prashantbasnet94

yarn add react-native-snap-carousel @types/react-native-snap-carousel

two packages, both

crastyle avatar Aug 03 '21 15:08 crastyle

Sorry, please allow me to advertise for my open source library! ~ I think this library react-native-reanimated-carousel will solve your problem. It is a high performance and very simple component, complete with React-Native reanimated 2

dohooo avatar Oct 08 '21 05:10 dohooo

I have the same issue can someone helppppp

mamonaabdullah122 avatar Jun 15 '22 16:06 mamonaabdullah122

您好,以下是自动回复内容:  您的来信我已收到,我会在尽快最短时间内回复您!  谢谢您的来信,祝您生活愉快

crastyle avatar Jun 15 '22 16:06 crastyle

Thanks

mamonaabdullah122 avatar Jun 16 '22 10:06 mamonaabdullah122

TypeError: Cannot read properties of undefined (reading 'hookChildProcess') in react native:

Running jetifier to migrate libraries to AndroidX. You can disable it using "--no-jetifier" flag. error Failed to run jetifier. TypeError: Cannot read properties of undefined (reading 'hookChildProcess') at module.exports (/Volumes/Os/ReactNativePROJECT/Educational/node_modules/react-native/node_modules/execa/index.js:308:22) at Object.runAndroid [as func] (/Volumes/Os/ReactNativePROJECT/Educational/node_modules/react-native/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/index.js:104:34) at Command.handleAction (/Volumes/Os/ReactNativePROJECT/Educational/node_modules/@react-native-community/cli/build/index.js:192:23) at Command.listener (/Volumes/Os/ReactNativePROJECT/Educational/node_modules/commander/index.js:315:8) at Command.emit (node:events:527:28) at Command.parseArgs (/Volumes/Os/ReactNativePROJECT/Educational/node_modules/commander/index.js:651:12) at Command.parse (/Volumes/Os/ReactNativePROJECT/Educational/node_modules/commander/index.js:474:21) at setupAndRun (/Volumes/Os/ReactNativePROJECT/Educational/node_modules/@react-native-community/cli/build/index.js:271:24) at run (/Volumes/Os/ReactNativePROJECT/Educational/node_modules/@react-native-community/cli/build/index.js:212:11) at Object. (/Volumes/Os/ReactNativePROJECT/Educational/node_modules/@react-native-community/cli/build/bin.js:8:11) info Run CLI with --verbose flag for more details.

mamonaabdullah122 avatar Jun 23 '22 17:06 mamonaabdullah122

I managed to run the example on android:

  • switch on f3d3e98a60b6203c60956bd7ec1b0f84adf8d7a5
  • use yarn instead of npm
  • update @babel/core, @babel/runtime, metro-react-native-babel-preset
  "dependencies": {
    "react": "16.9.0",
    "react-native": "0.61.5",
    "react-native-linear-gradient": "2.5.6",
    "react-native-snap-carousel": "file:../"
  },
  "devDependencies": {
    "@babel/core": "7.9.6",
    "@babel/runtime": "7.9.6",
    "babel-jest": "^24.9.0",
    "jest": "^24.9.0",
    "metro-react-native-babel-preset": "0.61.0",
    "react-test-renderer": "16.9.0"
  },

StanislavMayorov avatar Sep 01 '22 14:09 StanislavMayorov

您好,以下是自动回复内容:  您的来信我已收到,我会在尽快最短时间内回复您!  谢谢您的来信,祝您生活愉快

crastyle avatar Sep 01 '22 14:09 crastyle

yarn add react-native-snap-carousel @types/react-native-snap-carousel

two packages, both

Its work for me thanks for your help.

syeddastagir1 avatar May 18 '23 08:05 syeddastagir1