React Native Web + React Native Navigation #2767
Unanswered
taronsarkisyan
asked this question in
Q&A
Replies: 2 comments 2 replies
-
Additional information from React Native Navigation Additional information from ESBuild |
Beta Was this translation helpful? Give feedback.
0 replies
-
@taronsarkisyan |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Is there an existing issue for this?
Describe the issue
Description
Greetings, everyone.
I can't use the Expo framework due to project requirements.
Is it possible to use React Navigation in a vanilla React Native project that has React Native for Web installed?
The documentation states that this is possible,
but it doesn't explain how exactly:
https://reactnavigation.org/docs/web-support/
Can you provide a minimal example?
An example of React Native Navigation that works without Expo on the Web (ESBuild, Webpack or something else..)
Thanks.
Steps to reproduce
I tried to bundle using ESBuild:
and removed Flow types using this library:
https://www.npmjs.com/package/esbuild-plugin-flow
React Native Version
0.78.0
Affected Platforms
Runtime - Web
Console output
`✘ [ERROR] Could not resolve "react-native-web/Libraries/Utilities/codegenNativeComponent" (originally "react-native/Libraries/Utilities/codegenNativeComponent")
The path "react-native/Libraries/Utilities/codegenNativeComponent" was remapped to
"react-native-web/Libraries/Utilities/codegenNativeComponent" using the alias feature, which then
couldn't be resolved. Keep in mind that import path aliases are resolved in the current working
directory.
You can mark the path "react-native-web/Libraries/Utilities/codegenNativeComponent" as external to
exclude it from the bundle, which will remove this error and leave the unresolved path in the
bundle.
✘ [ERROR] Could not resolve "react-native-web/Libraries/Utilities/codegenNativeComponent" (originally "react-native/Libraries/Utilities/codegenNativeComponent")
The path "react-native/Libraries/Utilities/codegenNativeComponent" was remapped to
"react-native-web/Libraries/Utilities/codegenNativeComponent" using the alias feature, which then
couldn't be resolved. Keep in mind that import path aliases are resolved in the current working
directory.
You can mark the path "react-native-web/Libraries/Utilities/codegenNativeComponent" as external to
exclude it from the bundle, which will remove this error and leave the unresolved path in the
bundle. You can also surround this "require" call with a try/catch block to handle this failure at
run-time instead of bundle-time.
✘ [ERROR] Could not resolve "react-native-web/Libraries/Utilities/codegenNativeComponent" (originally "react-native/Libraries/Utilities/codegenNativeComponent")
The path "react-native/Libraries/Utilities/codegenNativeComponent" was remapped to
"react-native-web/Libraries/Utilities/codegenNativeComponent" using the alias feature, which then
couldn't be resolved. Keep in mind that import path aliases are resolved in the current working
directory.
You can mark the path "react-native-web/Libraries/Utilities/codegenNativeComponent" as external to
exclude it from the bundle, which will remove this error and leave the unresolved path in the
bundle. You can also surround this "require" call with a try/catch block to handle this failure at
run-time instead of bundle-time.
✘ [ERROR] Could not resolve "react-native-web/Libraries/Utilities/codegenNativeComponent" (originally "react-native/Libraries/Utilities/codegenNativeComponent")
The path "react-native/Libraries/Utilities/codegenNativeComponent" was remapped to
"react-native-web/Libraries/Utilities/codegenNativeComponent" using the alias feature, which then
couldn't be resolved. Keep in mind that import path aliases are resolved in the current working
directory.
You can mark the path "react-native-web/Libraries/Utilities/codegenNativeComponent" as external to
exclude it from the bundle, which will remove this error and leave the unresolved path in the
bundle. You can also surround this "require" call with a try/catch block to handle this failure at
run-time instead of bundle-time.
✘ [ERROR] Could not resolve "react-native-web/Libraries/Utilities/codegenNativeComponent" (originally "react-native/Libraries/Utilities/codegenNativeComponent")
The path "react-native/Libraries/Utilities/codegenNativeComponent" was remapped to
"react-native-web/Libraries/Utilities/codegenNativeComponent" using the alias feature, which then
couldn't be resolved. Keep in mind that import path aliases are resolved in the current working
directory.
You can mark the path "react-native-web/Libraries/Utilities/codegenNativeComponent" as external to
exclude it from the bundle, which will remove this error and leave the unresolved path in the
bundle.
✘ [ERROR] Could not resolve "react-native-web/Libraries/Utilities/codegenNativeComponent" (originally "react-native/Libraries/Utilities/codegenNativeComponent")
The path "react-native/Libraries/Utilities/codegenNativeComponent" was remapped to
"react-native-web/Libraries/Utilities/codegenNativeComponent" using the alias feature, which then
couldn't be resolved. Keep in mind that import path aliases are resolved in the current working
directory.
You can mark the path "react-native-web/Libraries/Utilities/codegenNativeComponent" as external to
exclude it from the bundle, which will remove this error and leave the unresolved path in the
bundle. You can also surround this "require" call with a try/catch block to handle this failure at
run-time instead of bundle-time.
✘ [ERROR] Could not resolve "react-native-web/Libraries/Utilities/codegenNativeComponent" (originally "react-native/Libraries/Utilities/codegenNativeComponent")
The path "react-native/Libraries/Utilities/codegenNativeComponent" was remapped to
"react-native-web/Libraries/Utilities/codegenNativeComponent" using the alias feature, which then
couldn't be resolved. Keep in mind that import path aliases are resolved in the current working
directory.
You can mark the path "react-native-web/Libraries/Utilities/codegenNativeComponent" as external to
exclude it from the bundle, which will remove this error and leave the unresolved path in the
bundle. You can also surround this "require" call with a try/catch block to handle this failure at
run-time instead of bundle-time.
✘ [ERROR] Could not resolve "react-native-web/Libraries/Utilities/codegenNativeComponent" (originally "react-native/Libraries/Utilities/codegenNativeComponent")
The path "react-native/Libraries/Utilities/codegenNativeComponent" was remapped to
"react-native-web/Libraries/Utilities/codegenNativeComponent" using the alias feature, which then
couldn't be resolved. Keep in mind that import path aliases are resolved in the current working
directory.
You can mark the path "react-native-web/Libraries/Utilities/codegenNativeComponent" as external to
exclude it from the bundle, which will remove this error and leave the unresolved path in the
bundle. You can also surround this "require" call with a try/catch block to handle this failure at
run-time instead of bundle-time.
✘ [ERROR] Could not resolve "react-native-web/Libraries/Utilities/codegenNativeComponent" (originally "react-native/Libraries/Utilities/codegenNativeComponent")
The path "react-native/Libraries/Utilities/codegenNativeComponent" was remapped to
"react-native-web/Libraries/Utilities/codegenNativeComponent" using the alias feature, which then
couldn't be resolved. Keep in mind that import path aliases are resolved in the current working
directory.
You can mark the path "react-native-web/Libraries/Utilities/codegenNativeComponent" as external to
exclude it from the bundle, which will remove this error and leave the unresolved path in the
bundle. You can also surround this "require" call with a try/catch block to handle this failure at
run-time instead of bundle-time.
✘ [ERROR] Could not resolve "react-native-web/Libraries/Utilities/codegenNativeComponent" (originally "react-native/Libraries/Utilities/codegenNativeComponent")
The path "react-native/Libraries/Utilities/codegenNativeComponent" was remapped to
"react-native-web/Libraries/Utilities/codegenNativeComponent" using the alias feature, which then
couldn't be resolved. Keep in mind that import path aliases are resolved in the current working
directory.
You can mark the path "react-native-web/Libraries/Utilities/codegenNativeComponent" as external to
exclude it from the bundle, which will remove this error and leave the unresolved path in the
bundle. You can also surround this "require" call with a try/catch block to handle this failure at
run-time instead of bundle-time.
✘ [ERROR] Could not resolve "react-native-web/Libraries/ReactNative/AppContainer" (originally "react-native/Libraries/ReactNative/AppContainer")
The path "react-native/Libraries/ReactNative/AppContainer" was remapped to
"react-native-web/Libraries/ReactNative/AppContainer" using the alias feature, which then couldn't
be resolved. Keep in mind that import path aliases are resolved in the current working directory.
You can mark the path "react-native-web/Libraries/ReactNative/AppContainer" as external to exclude
it from the bundle, which will remove this error and leave the unresolved path in the bundle. You
can also surround this "require" call with a try/catch block to handle this failure at run-time
instead of bundle-time.
✘ [ERROR] Could not resolve "react-native-web/Libraries/Utilities/codegenNativeComponent" (originally "react-native/Libraries/Utilities/codegenNativeComponent")
The path "react-native/Libraries/Utilities/codegenNativeComponent" was remapped to
"react-native-web/Libraries/Utilities/codegenNativeComponent" using the alias feature, which then
couldn't be resolved. Keep in mind that import path aliases are resolved in the current working
directory.
You can mark the path "react-native-web/Libraries/Utilities/codegenNativeComponent" as external to
exclude it from the bundle, which will remove this error and leave the unresolved path in the
bundle. You can also surround this "require" call with a try/catch block to handle this failure at
run-time instead of bundle-time.
✘ [ERROR] Could not resolve "react-native-web/Libraries/Utilities/codegenNativeCommands" (originally "react-native/Libraries/Utilities/codegenNativeCommands")
The path "react-native/Libraries/Utilities/codegenNativeCommands" was remapped to
"react-native-web/Libraries/Utilities/codegenNativeCommands" using the alias feature, which then
couldn't be resolved. Keep in mind that import path aliases are resolved in the current working
directory.
You can mark the path "react-native-web/Libraries/Utilities/codegenNativeCommands" as external to
exclude it from the bundle, which will remove this error and leave the unresolved path in the
bundle. You can also surround this "require" call with a try/catch block to handle this failure at
run-time instead of bundle-time.
✘ [ERROR] Could not resolve "react-native-web/Libraries/Utilities/codegenNativeComponent" (originally "react-native/Libraries/Utilities/codegenNativeComponent")
The path "react-native/Libraries/Utilities/codegenNativeComponent" was remapped to
"react-native-web/Libraries/Utilities/codegenNativeComponent" using the alias feature, which then
couldn't be resolved. Keep in mind that import path aliases are resolved in the current working
directory.
You can mark the path "react-native-web/Libraries/Utilities/codegenNativeComponent" as external to
exclude it from the bundle, which will remove this error and leave the unresolved path in the
bundle. You can also surround this "require" call with a try/catch block to handle this failure at
run-time instead of bundle-time.
✘ [ERROR] Could not resolve "react-native-web/Libraries/Utilities/codegenNativeComponent" (originally "react-native/Libraries/Utilities/codegenNativeComponent")
The path "react-native/Libraries/Utilities/codegenNativeComponent" was remapped to
"react-native-web/Libraries/Utilities/codegenNativeComponent" using the alias feature, which then
couldn't be resolved. Keep in mind that import path aliases are resolved in the current working
directory.
You can mark the path "react-native-web/Libraries/Utilities/codegenNativeComponent" as external to
exclude it from the bundle, which will remove this error and leave the unresolved path in the
bundle. You can also surround this "require" call with a try/catch block to handle this failure at
run-time instead of bundle-time.
1472 | let { file, line, column } = e.location;
1473 | let pluginText = e.pluginName ?
[plugin: ${e.pluginName}]
: "";1474 | return
1475 | ${file}:${line}:${column}: ERROR: ${pluginText}${e.text}
;1476 | }).join("");
1477 | let error = new Error(text);
^
error: Build failed with 15 errors:
node_modules/react-native-safe-area-context/lib/module/specs/NativeSafeAreaProvider.js:1:35: ERROR: Could not resolve "react-native-web/Libraries/Utilities/codegenNativeComponent" (originally "react-native/Libraries/Utilities/codegenNativeComponent")
node_modules/react-native-safe-area-context/lib/module/specs/NativeSafeAreaView.js:1:35: ERROR: Could not resolve "react-native-web/Libraries/Utilities/codegenNativeComponent" (originally "react-native/Libraries/Utilities/codegenNativeComponent")
node_modules/react-native-screens/lib/commonjs/components/DebugContainer.js:9:51: ERROR: Could not resolve "react-native-web/Libraries/ReactNative/AppContainer" (originally "react-native/Libraries/ReactNative/AppContainer")
node_modules/react-native-screens/lib/commonjs/fabric/FullWindowOverlayNativeComponent.js:8:61: ERROR: Could not resolve "react-native-web/Libraries/Utilities/codegenNativeComponent" (originally "react-native/Libraries/Utilities/codegenNativeComponent")
node_modules/react-native-screens/lib/commonjs/fabric/ModalScreenNativeComponent.js:8:61: ERROR: Could not resolve "react-native-web/Libraries/Utilities/codegenNativeComponent" (originally "react-native/Libraries/Utilities/codegenNativeComponent")
...
at failureErrorWithLog (/var/www/node/node_modules/esbuild/lib/main.js:1477:15)
at (/var/www/node/node_modules/esbuild/lib/main.js:946:25)
at (/var/www/node/node_modules/esbuild/lib/main.js:1355:9)`
Expected behavior
React Native Navigation works on vanilla React Native on Web 🙂 👍🏻
Steps to reproduce
Test case
https://github.com/necolas/react-native-web
Additional comments
No response
Beta Was this translation helpful? Give feedback.
All reactions