admin管理员组文章数量:1023838
I'm working on my first React Native project using React Native with Expo, and I'm encountering a frustrating issue. The project runs fine on the Expo Go app on my Android device, but when I try to view it in a web browser on my Windows laptop, I keep getting the following error:
Metro error: Cannot find module 'react'
Require stack:
- /C:%5CUsers%5CMuhammed%20Tauqeer%20Ali%5CSocialSphere%5Cnode_modules%5Cexpo-router%5Cnode%5Crender.js.bundle?platform=web&dev=true&hot=false&transform.engine=hermes&transform.routerRoot=app&resolver.environment=node&transform.environment=node&unstable_transformProfile=hermes-stable
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\src\start\server\getStaticRenderFunctions.js
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\src\start\server\metro\metroErrorInterface.js
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\src\start\server\metro\createServerComponentsMiddleware.js
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\src\start\server\metro\MetroBundlerDevServer.js
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\src\start\server\DevServerManager.js
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\src\start\startAsync.js
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\src\start\index.js
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\bin\cli
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\expo\bin\cli
The following is the image from web browser:
Here's what I've tried so far:
- Installed
react
andreact-dom
withnpm install react react-dom
. - Cleared the Metro Bundler cache with
npx expo start --clear
. - Ran
npx expo-doctor
, which didn't find any errors or problems.
Besides these, I did also tried a few things from YouTube. But despite all these efforts, the error persists.
I'm working on my first React Native project using React Native with Expo, and I'm encountering a frustrating issue. The project runs fine on the Expo Go app on my Android device, but when I try to view it in a web browser on my Windows laptop, I keep getting the following error:
Metro error: Cannot find module 'react'
Require stack:
- /C:%5CUsers%5CMuhammed%20Tauqeer%20Ali%5CSocialSphere%5Cnode_modules%5Cexpo-router%5Cnode%5Crender.js.bundle?platform=web&dev=true&hot=false&transform.engine=hermes&transform.routerRoot=app&resolver.environment=node&transform.environment=node&unstable_transformProfile=hermes-stable
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\src\start\server\getStaticRenderFunctions.js
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\src\start\server\metro\metroErrorInterface.js
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\src\start\server\metro\createServerComponentsMiddleware.js
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\src\start\server\metro\MetroBundlerDevServer.js
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\src\start\server\DevServerManager.js
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\src\start\startAsync.js
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\src\start\index.js
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\bin\cli
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\expo\bin\cli
The following is the image from web browser:
Here's what I've tried so far:
- Installed
react
andreact-dom
withnpm install react react-dom
. - Cleared the Metro Bundler cache with
npx expo start --clear
. - Ran
npx expo-doctor
, which didn't find any errors or problems.
Besides these, I did also tried a few things from YouTube. But despite all these efforts, the error persists.
Share Improve this question edited Nov 15, 2024 at 5:27 James Z 12.3k10 gold badges27 silver badges47 bronze badges asked Nov 14, 2024 at 20:14 user24809029user24809029 555 bronze badges3 Answers
Reset to default 9Update your Expo configuration from "output": "static" to "output": "single" in app.json file. Then start the development server again.(npx expo start)
make sure, you have no spaces in the path of your project. If you have spaces and need them, try to change the expo configuration
{"expo":{
...
"web": {
...
"output": "single"
instead of "output": "static". After the change expo needs to be restarted
make sure there is no whitespace in your path. Open file in Mac Finder or Windows Explorer, remove whitespaces, save and close/quit your editor/VSCode, reopen.
I'm working on my first React Native project using React Native with Expo, and I'm encountering a frustrating issue. The project runs fine on the Expo Go app on my Android device, but when I try to view it in a web browser on my Windows laptop, I keep getting the following error:
Metro error: Cannot find module 'react'
Require stack:
- /C:%5CUsers%5CMuhammed%20Tauqeer%20Ali%5CSocialSphere%5Cnode_modules%5Cexpo-router%5Cnode%5Crender.js.bundle?platform=web&dev=true&hot=false&transform.engine=hermes&transform.routerRoot=app&resolver.environment=node&transform.environment=node&unstable_transformProfile=hermes-stable
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\src\start\server\getStaticRenderFunctions.js
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\src\start\server\metro\metroErrorInterface.js
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\src\start\server\metro\createServerComponentsMiddleware.js
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\src\start\server\metro\MetroBundlerDevServer.js
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\src\start\server\DevServerManager.js
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\src\start\startAsync.js
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\src\start\index.js
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\bin\cli
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\expo\bin\cli
The following is the image from web browser:
Here's what I've tried so far:
- Installed
react
andreact-dom
withnpm install react react-dom
. - Cleared the Metro Bundler cache with
npx expo start --clear
. - Ran
npx expo-doctor
, which didn't find any errors or problems.
Besides these, I did also tried a few things from YouTube. But despite all these efforts, the error persists.
I'm working on my first React Native project using React Native with Expo, and I'm encountering a frustrating issue. The project runs fine on the Expo Go app on my Android device, but when I try to view it in a web browser on my Windows laptop, I keep getting the following error:
Metro error: Cannot find module 'react'
Require stack:
- /C:%5CUsers%5CMuhammed%20Tauqeer%20Ali%5CSocialSphere%5Cnode_modules%5Cexpo-router%5Cnode%5Crender.js.bundle?platform=web&dev=true&hot=false&transform.engine=hermes&transform.routerRoot=app&resolver.environment=node&transform.environment=node&unstable_transformProfile=hermes-stable
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\src\start\server\getStaticRenderFunctions.js
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\src\start\server\metro\metroErrorInterface.js
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\src\start\server\metro\createServerComponentsMiddleware.js
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\src\start\server\metro\MetroBundlerDevServer.js
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\src\start\server\DevServerManager.js
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\src\start\startAsync.js
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\src\start\index.js
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\@expo\cli\build\bin\cli
- C:\Users\Muhammed Tauqeer Ali\SocialSphere\node_modules\expo\bin\cli
The following is the image from web browser:
Here's what I've tried so far:
- Installed
react
andreact-dom
withnpm install react react-dom
. - Cleared the Metro Bundler cache with
npx expo start --clear
. - Ran
npx expo-doctor
, which didn't find any errors or problems.
Besides these, I did also tried a few things from YouTube. But despite all these efforts, the error persists.
Share Improve this question edited Nov 15, 2024 at 5:27 James Z 12.3k10 gold badges27 silver badges47 bronze badges asked Nov 14, 2024 at 20:14 user24809029user24809029 555 bronze badges3 Answers
Reset to default 9Update your Expo configuration from "output": "static" to "output": "single" in app.json file. Then start the development server again.(npx expo start)
make sure, you have no spaces in the path of your project. If you have spaces and need them, try to change the expo configuration
{"expo":{
...
"web": {
...
"output": "single"
instead of "output": "static". After the change expo needs to be restarted
make sure there is no whitespace in your path. Open file in Mac Finder or Windows Explorer, remove whitespaces, save and close/quit your editor/VSCode, reopen.
本文标签: javascriptCannot find module 39react39 Error When Running Expo Project in Web BrowserStack Overflow
版权声明:本文标题:javascript - Cannot find module 'react' Error When Running Expo Project in Web Browser - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745519794a2154262.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论