LuanRT / YouTube.js

A wrapper around YouTube's internal API — reverse engineering InnerTube
https://www.npmjs.com/package/youtubei.js
MIT License
3.3k stars 199 forks source link

10.0.0 Running in RN + Expo CRASH BUNDLE #667

Open giovanijfc opened 3 weeks ago

giovanijfc commented 3 weeks ago

Steps to reproduce

Hi, I installed the lib in version 10.0.0 and in my app made in react-native 0.72.6 + expo 49.0.15 and the bundle is breaking.

Failure Logs

Android Bundling failed 333ms
error: Error: The package `/node_modules/youtubei.js/package.json` is invalid because it specifies a `main` module field that could not be resolved (`/node_modules/youtubei.js/index`. None of these files exist:

  * /node_modules/youtubei.js/index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.cjs|.native.cjs|.cjs)
  * /node_modules/youtubei.js/index/index(.native|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.cjs|.native.cjs|.cjs)
    at resolvePackageEntryPoint (/node_modules/metro-resolver/src/resolve.js:339:11)
    at resolveModulePath (/node_modules/metro-resolver/src/resolve.js:172:21)
    at resolvePackage (/node_modules/metro-resolver/src/resolve.js:299:10)
    at resolve (/node_modules/metro-resolver/src/resolve.js:138:20)
    at doResolve (/node_modules/@expo/cli/build/src/start/server/metro/withMetroMultiPlatform.js:181:24)
    at /node_modules/@expo/cli/build/src/start/server/metro/withMetroMultiPlatform.js:217:48
    at resolveRequest (/node_modules/@expo/cli/build/src/start/server/metro/withMetroResolvers.js:30:44)
    at Object.resolve (/node_modules/metro/node_modules/metro-resolver/src/resolve.js:47:12)
    at ModuleResolver.resolveDependency (/node_modules/metro/src/node-haste/DependencyGraph/ModuleResolution.js:86:31)
    at DependencyGraph.resolveDependency (/node_modules/metro/src/node-haste/DependencyGraph.js:282:43)

Expected behavior

The app loaded the bundle without a problem

Current behavior

The bundle crashes while I keep importing the module

Version

Default

Anything else?

No response

Checklist

nohwolde commented 3 weeks ago

facing the same issue as above, metro requires a main file to be specified or an index.js to be present in any node module packages. adding "main": "./bundle/react-native.js", to the package.json allows for successful import and usage of the library, however I'm not sure if this is too hacky or will leave things out that are necessary for other functionality that I haven't tested yet

absidue commented 3 weeks ago

Please make sure you both fully follow the react-native instructions: https://github.com/LuanRT/YouTube.js/blob/main/src/platform/react-native.md

nohwolde commented 3 weeks ago

Please make sure you both fully follow the react-native instructions: https://github.com/LuanRT/YouTube.js/blob/main/src/platform/react-native.md

yes I made sure to follow that but even with adding those configs it didn't change anything metro still isn't able to find the main file without adding that line to the package.json. The error might have something to do with myself and the original poster using expo since I know you can also use React native cli as well.