I am getting this error when upgrade my react native.
It says
Error: Unable to resolve module ./index from \node_modules\react-native\scripts/.: The module ./index could not be found from \node_modules\react-native\scripts/.. Indeed, none of these files exist:
react-native run-android
Should run the App
{
"name": "RedCrow",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"test": "jest"
},
"dependencies": {
"axios": "^0.18.0",
"leaflet": "^1.4.0",
"moment": "^2.24.0",
"native-base": "^2.12.1",
"node-pre-gyp": "^0.12.0",
"prop-types": "^15.7.2",
"react": "^16.8.4",
"react-dom": "^16.8.4",
"react-leaflet": "^2.2.1",
"react-native": "^0.59.0",
"react-native-camera": "^1.13.1",
"react-native-fs": "^2.13.3",
"react-native-gesture-handler": "^1.1.0",
"react-native-image-crop-picker": "^0.22.0",
"react-native-image-picker": "^0.28.0",
"react-native-modal": "^7.0.2",
"react-native-vector-icons": "^6.4.1",
"react-native-video": "^4.4.0",
"react-native-webview": "^5.3.0",
"react-native-webview-leaflet": "^4.1.22",
"react-navigation": "^3.3.2",
"react-navigation-props-mapper": "^0.3.0",
"react-redux": "^6.0.1",
"realm": "^2.25.0",
"redux": "^4.0.1",
"redux-form": "^8.1.0",
"rn-fetch-blob": "^0.10.15",
"util": "*"
},
"devDependencies": {
"babel-jest": "^24.5.0",
"jest": "^24.5.0",
"metro-react-native-babel-preset": "0.51.1",
"react-test-renderer": "16.6.3"
},
"jest": {
"preset": "react-native"
}
}
"react": "^16.8.4",
"react-native": "^0.59.0",
Can you run react-native info
and edit your issue to include these results under the Environment section?
[skip envinfo]
alongside an explanation in your Environment: section.
@moinulhuq! Yeah I have been the same :(.
same issues
Got the same issue initially with yarn start
but after running react-native start -- --reset-cache
got the following error message:
*I am inside the right folder btw
I restore my project and use new new method to upgrade:
1.change the version of react and react-native
"react": "16.8.3",
"react-native": "0.59.0",
2 .run npm install then react-native upgrade --legacy ,that will change your some files (decide whether to cover as needed)
NOTE: One difference between my error and OP's is I'm unable to resolve the module ./index
from /node_modules/react-native/.
(as opposed to /node_modules/react-native/scripts/.
).
I'll second this. After upgrading from 0.58.6
to 0.59.1
I get this error on both iOS and Android. Here is my react-native info
output:
info
React Native Environment Info:
System:
OS: Linux 4.18 Ubuntu 18.10 (Cosmic Cuttlefish)
CPU: (16) x64 AMD Ryzen 7 2700X Eight-Core Processor
Memory: 389.57 MB / 15.68 GB
Shell: 5.5.1 - /usr/bin/zsh
Binaries:
Node: 11.10.1 - /usr/bin/node
Yarn: 1.13.0 - /usr/bin/yarn
npm: 6.7.0 - /usr/bin/npm
SDKs:
Android SDK:
API Levels: 23, 24, 25, 26, 27, 28
Build Tools: 28.0.2, 28.0.3
System Images: android-28 | Google APIs Intel x86 Atom
IDEs:
Android Studio: 3.3 AI-182.5107.16.33.5314842
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.1 => 0.59.1
npmGlobalPackages:
react-native-cli: 2.0.1
I can't imagine it's an issue with specific Android/iOS config and build files since I get the same error across platforms, but I can provide them if necessary. My gradle version is ~4.10.2
and Android SDK version is ~28
.
I've taken the usual steps when encountering a problem while updating RN:
$TMPDIR
node_modules
react-native start -- --reset-cache
No luck so far, any help would be appreciated.
same issue + 1
After creating a new project using React-native 0.59 , i copied metro.config.js
, .flowconfig
and babel.config.js
to the old project and it started to work again
the issue only happens when I press Play
button and build using xcode, but when I run npm start -- --reset-cache
it will works
Moved iOS build cache directory from ~/.rncache to ~/Library/Caches/com.facebook.ReactNativeBuild
Could be because the cache directory already changed
refer to @chenxin0916 ,Handing conflicts
then
run react-native start --cache-reset
to clear the bundle cache first
now you can run-ios/android
run
react-native start -- --reset-cache
then
react-native run-android
in separate command line
works fine for me, maybe just for a temporary solution.
there is another solution from @nazreinkaram by updating launchPackager.bat
, no need to open two cmd line. thanks
NOTE: One difference between my error and OP's is I'm unable to resolve the module
./index
from/node_modules/react-native/.
(as opposed to/node_modules/react-native/scripts/.
).I'll second this. After upgrading from
0.58.6
to0.59.1
I get this error on both iOS and Android. Here is myreact-native info
output:info React Native Environment Info: System: OS: Linux 4.18 Ubuntu 18.10 (Cosmic Cuttlefish) CPU: (16) x64 AMD Ryzen 7 2700X Eight-Core Processor Memory: 389.57 MB / 15.68 GB Shell: 5.5.1 - /usr/bin/zsh Binaries: Node: 11.10.1 - /usr/bin/node Yarn: 1.13.0 - /usr/bin/yarn npm: 6.7.0 - /usr/bin/npm SDKs: Android SDK: API Levels: 23, 24, 25, 26, 27, 28 Build Tools: 28.0.2, 28.0.3 System Images: android-28 | Google APIs Intel x86 Atom IDEs: Android Studio: 3.3 AI-182.5107.16.33.5314842 npmPackages: react: 16.8.3 => 16.8.3 react-native: 0.59.1 => 0.59.1 npmGlobalPackages: react-native-cli: 2.0.1
I can't imagine it's an issue with specific Android/iOS config and build files since I get the same error across platforms, but I can provide them if necessary. My gradle version is
~4.10.2
and Android SDK version is~28
.I've taken the usual steps when encountering a problem while updating RN:
- deleting React, metro, yarn, and haste caches in
$TMPDIR
- deleting
node_modules
react-native start -- --reset-cache
- cleaning build folders for both iOS and Android
No luck so far, any help would be appreciated.
I have the same issue. Have you found the solution?
After creating a new project using React-native 0.59 , i copied
metro.config.js
,.flowconfig
andbabel.config.js
to the old project and it started to work again
Thanks you. I tried and success :). Everyone can try
I get the same issu on IOS,
after cache clear i get app stuck on "downloading javascript bundle 100%" and black screen below,
no error on metro console, when debug mode is on.
if i remove debug mode the app start. but need debug. any idea ? thanks
After creating a new project using React-native 0.59 , i copied
metro.config.js
,.flowconfig
andbabel.config.js
to the old project and it started to work again
I just copied metro.config.js
and it works perfectly. Thanks a lot
can someone past the content and path of the metro.config.js
file please ?
I have one in
Hello everyone - this issue seems to be related to your experience upgrading between versions. We know this has been a long lasting pain for the community so starting v0.59 we have introduced a new flow via the new CLI.
But, to upgrade to that version, you still need some potentially manual steps - we suggest you use the rn-diff-repo to accomplish this.
Given that this is not strictly a bug with the library itself I'll close this, but if someone can create a repro that has this issue with a freshly created react-native init
project we can reopen it and discuss it further 🤗
@alainib you can use the one in https://github.com/facebook/react-native/tree/0.59-stable/template
Thanks @kelset! It took me a while to fix this. Like @saraztr and others said, copying metro.config.js from a 0.59 new project fixes the issue.
@alainib , here's the metro.config.js content:
/**
* Metro configuration for React Native
* https://github.com/facebook/react-native
*
* @format
*/
module.exports = {
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
},
};
same issues
Error: Unable to resolve module ./index
from node_modules\react-native\scripts/.: The module
./indexcould not be found from
node_modules\react-native\scripts/.`
React Native Environment Info:
System:
OS: Windows 10
CPU: (4) x64 Intel(R) Core(TM) i3-3110M CPU @ 2.40GHz
Memory: 569.59 MB / 3.89 GB
Binaries:
Yarn: 1.12.3 - C:\Users\Vivek\AppData\Roaming\npm\yarn.CMD
npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
IDEs:
Android Studio: Version 3.3.0.0 AI-182.5107.16.33.5314842
Environment :
"react": "16.8.3",
"react-moment": "^0.8.4"
@VivekkChudasama try to
npm cache clean --force
metro.config.js
posted before@VivekkChudasama WHat do you mean by put the metro.config.js posted before?
@ahmad6242, create a new file in your RN project root folder named metro.config.js with the content below:
/**
module.exports = {
transformer: {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
},
};
I tried cleaning the cache, removing the node_modules directory and reinstalling using npm install
, with no luck. I already had a metro.config.js file in the project root directory. I am using react v16.8.5 and react-native v0.59.1
I tried cleaning the cache, removing the node_modules directory and reinstalling using
npm install
, with no luck. I already had a metro.config.js file in the project root directory. I am using react v16.8.5 and react-native v0.59.1
did you have last metro in dev dependancies ?
Same issue, I even tried a new app from scratch without changing anything and I got the same error...
```
React Native Environment Info:
System:
OS: macOS 10.14.1
CPU: (12) x64 Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz
Memory: 107.03 MB / 16.00 GB
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 11.12.0 - /usr/local/bin/node
Yarn: 1.15.2 - /usr/local/bin/yarn
npm: 6.7.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1
IDEs:
Xcode: 10.1/10B61 - /usr/bin/xcodebuild
npmPackages:
react: 16.8.3 => 16.8.3
react-native: 0.59.1 => 0.59.1
npmGlobalPackages:
react-native-cli: 2.0.1
And i have same issue, with new app:
react-native init TestProject --template typescript
@soetedja solution helped me
And i have same issue, with new app:
react-native init TestProject --template typescript
@soetedja solution helped me
After creating a new project using React-native 0.59 , i copied
metro.config.js
,.flowconfig
andbabel.config.js
to the old project and it started to work againI just copied
metro.config.js
and it works perfectly. Thanks a lot
Can you please explain it clearly. If I am using React-native 0.59 project what should I do to resolve from this error
run
react-native start -- --reset-cache
then
react-native run-android
in separate command lineworks fine for me
Thankyou..It worked for me
Hi all,
I have the same issue after installing react-native vector icons. I tried to create new app to check but it still failed. I don't know why. I tried some solutions up there but it still not work.
Please help me!
Thanks in advance!
Nothing works still getting the same error
can someone help me out with this exactly
Same problem here. I have built an app with react-native init test-project
and I have obtained the error reported here. Reset cache did not work.
@devangelmotta it just happen today it was working fine till yesterday..!!
Metro server instance here is started by runAndroid.js
if you ask for react-native run-android
I can help you with android only, I am giving you fix on windows, if you are on Linux then I am sure you definitely know how to apply these fixes on your machine.
Problem is with Working Directory, Metro instance is launched with wrong working directory and no project root is passed in launchPackager
Threre are two fixes for this issue, apply only one of the below
node_modules\react-native\scripts\launchPackager.bat
file.@echo off
title Metro Bundler
call .packager.bat
:: delete this line
node "%~dp0..\cli.js" start
:: Add this line
node "%~dp0..\cli.js" start --projectRoot ../../../
pause
exit
We are giving project root path to Metro instance here,
\node_modules\@react-native-community\cli\build\commands\runAndroid\runAndroid.js
edit this,const procConfig = {
// delete this line
cwd: scriptsDir
// add this line
cwd: process.cwd()
};
We launched Metro launcher with working directory to our project root
Thanks alot @nazreinkaram
thank
Metro server instance here is started by
runAndroid.js
if you ask forreact-native run-android
I can help you with android only, I am giving you fix on windows, if you are on Linux then I am sure you definitely know how to apply these fixes on your machine.
Problem is with Working Directory, Metro instance is launched with wrong working directory and no project root is passed in
launchPackager
Threre are two fixes for this issue, apply only one of the below
Update
node_modules\react-native\scripts\launchPackager.bat
file.@echo off title Metro Bundler call .packager.bat // delete this line node "%~dp0..\cli.js" start Add this line node "%~dp0..\cli.js" start --projectRoot ../../../ pause exit
We are giving project root path to Metro instance here,
Or in
\node_modules\@react-native-community\cli\build\commands\runAndroid\runAndroid.js
edit this,const procConfig = { // delete this line cwd: scriptsDir // add this line cwd: process.cwd() };
We launched Metro launcher with working directory to our project root
thanks alot bro .
your solution worked for me
react-native start -- --reset-cache
Why should i always suppose to write this
Metro server instance here is started by
runAndroid.js
if you ask forreact-native run-android
I can help you with android only, I am giving you fix on windows, if you are on Linux then I am sure you definitely know how to apply these fixes on your machine.
Problem is with Working Directory, Metro instance is launched with wrong working directory and no project root is passed in
launchPackager
Threre are two fixes for this issue, apply only one of the below
Update
node_modules\react-native\scripts\launchPackager.bat
file.@echo off title Metro Bundler call .packager.bat // delete this line node "%~dp0..\cli.js" start Add this line node "%~dp0..\cli.js" start --projectRoot ../../../ pause exit
We are giving project root path to Metro instance here,
Or in
\node_modules\@react-native-community\cli\build\commands\runAndroid\runAndroid.js
edit this,const procConfig = { // delete this line cwd: scriptsDir // add this line cwd: process.cwd() };
We launched Metro launcher with working directory to our project root
Thanks Buddy This is working for me Also.....
thanks a lot
Metro server instance here is started by
runAndroid.js
if you ask forreact-native run-android
I can help you with android only, I am giving you fix on windows, if you are on Linux then I am sure you definitely know how to apply these fixes on your machine.
Problem is with Working Directory, Metro instance is launched with wrong working directory and no project root is passed in
launchPackager
Threre are two fixes for this issue, apply only one of the below
Update
node_modules\react-native\scripts\launchPackager.bat
file.@echo off title Metro Bundler call .packager.bat // delete this line node "%~dp0..\cli.js" start Add this line node "%~dp0..\cli.js" start --projectRoot ../../../ pause exit
We are giving project root path to Metro instance here,
Or in
\node_modules\@react-native-community\cli\build\commands\runAndroid\runAndroid.js
edit this,const procConfig = { // delete this line cwd: scriptsDir // add this line cwd: process.cwd() };
We launched Metro launcher with working directory to our project root
Thanks a lot. It works for me
@nazreinkaram 's solution worked for me too. The first one that is.
Maybe this is just me, but:
react-native start -- --reset-cache
returns
error Unexpected token <
Also, starting new project using react-native init blablabla
and thencd blablabla
then react-native run-android
gives me the same error.
However, the error went away if I use expo.
@kelset This seems to be an issue with new project. Please reopen.
Yeah, this seems to still be an issue. Installed a clean version of react-native, npm, node etc and am unable to call react-native run-ios
alone. I first need to run react-native start -- --reset-cache
in a seperate terminal to get my vanilla app to work. Note I've not changed anything in the generated project.
Metro server instance here is started by
runAndroid.js
if you ask forreact-native run-android
I can help you with android only, I am giving you fix on windows, if you are on Linux then I am sure you definitely know how to apply these fixes on your machine.
Problem is with Working Directory, Metro instance is launched with wrong working directory and no project root is passed in
launchPackager
Threre are two fixes for this issue, apply only one of the below
Update
node_modules\react-native\scripts\launchPackager.bat
file.@echo off title Metro Bundler call .packager.bat // delete this line node "%~dp0..\cli.js" start Add this line node "%~dp0..\cli.js" start --projectRoot ../../../ pause exit
We are giving project root path to Metro instance here,
Or in
\node_modules\@react-native-community\cli\build\commands\runAndroid\runAndroid.js
edit this,const procConfig = { // delete this line cwd: scriptsDir // add this line cwd: process.cwd() };
We launched Metro launcher with working directory to our project root
The only way to run vanilla app is to update above workaround from our savior @nazreinkaram . Or, initiate using EXPO.
I can't believe a fresh app, started from scratch, can't run.
Edit: nvm, found it.
Edit 2: Well, still not working after changing runAndroid.js. Same index.js not found error.
Edit3: On mac, option 2 did not work. However, option 1 (edit node_modules/react-native/scripts/packager.sh) with node "./cli.js" start --projectRoot ../../
worked.
I can't believe a fresh app, started from scratch, can't run.
Edit: nvm, found it.
Edit 2: Well, still not working after changing runAndroid.js. Same index.js not found error.
Edit3: On mac, option 2 did not work. However, option 1 (edit node_modules/react-native/scripts/packager.sh) with
node "./cli.js" start --projectRoot ../../
worked.
Why would changing runAndroid.js
will work on mac? I guess you are creating iOS app on it, so runAndroid.js
gets executed only for android devices
There exists a runIOS.js
in @react-native-community\cli\build\commands\runIOS
. Tempering this file accordingly may work but I am not sure as I haven't looked into it. Good Luck
I can't believe a fresh app, started from scratch, can't run.
Edit: nvm, found it.
Edit 2: Well, still not working after changing runAndroid.js. Same index.js not found error.
Edit3: On mac, option 2 did not work. However, option 1 (edit node_modules/react-native/scripts/packager.sh) withnode "./cli.js" start --projectRoot ../../
worked.Why would changing
runAndroid.js
will work on mac? I guess you are creating iOS app on it, sorunAndroid.js
gets executed only for android devicesThere exists a
runOS.js
in@react-native-community\cli\build\commands\runIOS
. Tempering this file accordingly may work but I am not sure as I haven't looked into it. Good Luck
Because I'm also running Android on Mac? But never mind, option 1 works fine. I still can't believe this is an issue though.
P.S: replied with a wrong account previously :)
run
react-native start -- --reset-cache
then
react-native run-android
in separate command lineworks fine for me
Tanks, @soetedja It worked for me too
I can't believe a fresh app, started from scratch, can't run.
Edit: nvm, found it.
Edit 2: Well, still not working after changing runAndroid.js. Same index.js not found error.
Edit3: On mac, option 2 did not work. However, option 1 (edit node_modules/react-native/scripts/packager.sh) withnode "./cli.js" start --projectRoot ../../
worked.Why would changing
runAndroid.js
will work on mac? I guess you are creating iOS app on it, sorunAndroid.js
gets executed only for android devices
There exists arunOS.js
in@react-native-community\cli\build\commands\runIOS
. Tempering this file accordingly may work but I am not sure as I haven't looked into it. Good LuckBecause I'm also running Android on Mac? But never mind, option 1 works fine. I still can't believe this is an issue though.
P.S: replied with a wrong account previously :)
If you are curious you should try debugging, At least try to add a breakpoint or simply console.log
inrunAndroid.js
before spawn()
in startServerInNewWindow()
to check what exactly is getting passed into spawn
as third param for launching bat file.
run
react-native start -- --reset-cache
then
react-native run-android
in separate command lineworks fine for me
this one worked for me thanks
react-native start -- --reset-cache
然后
react-native run-android
在单独的命令行中运行对我来说很好
Thanks
@kelset pls re-open and check out @nazreinkaram's response
@VivekkChudasama try to
npm cache clean --force
- install metro in package.json devDependencies
- put the
metro.config.js
posted before- remove node_modules folder and npm install again
- gradlew clean on android (cd android ; ./gradlew clean ; cd .. )
- remove pods folder on ios and install again (cd ios ; pod install ; cd .. )
All Ready Update react-native version and metro.config.js available in posted before.
react-native start -- --reset-cache
- after Run - react-native run-android
- clear cache after 2time run this command after successfully build.
Thanks a lot. It works for me
I resolved it by rollback the RN version.
modify package.json
"react-native": "0.58.6"
then clear cache:
cd path/to/project
rm -rf ~/.rncache
rm package-lock.json
sudo rm $TMPDIR/*
sudo rm -rf $TMPDIR/*
watchman watch-del-all
watchman watch-del-all
rm yarn.lock
rm -rf node_modules/
rm -rf android/build
#install node_modules
yarn
react-native link
#run simulator
react-native run-android
@nazreinkaram Thanks you so much. It's end up my 4 hours to fix this prob.
step 1: npm install concurrently -D
step 2: add in your package.json scripts(start) "concurrently \"react-native start --reset-cache\" \"react-native run-android\""
step 3 : npm start
Metro server instance here is started by
runAndroid.js
if you ask forreact-native run-android
I can help you with android only, I am giving you fix on windows, if you are on Linux then I am sure you definitely know how to apply these fixes on your machine.
Problem is with Working Directory, Metro instance is launched with wrong working directory and no project root is passed inlaunchPackager
Threre are two fixes for this issue, apply only one of the belowUpdate
node_modules\react-native\scripts\launchPackager.bat
file.@echo off title Metro Bundler call .packager.bat // delete this line node "%~dp0..\cli.js" start Add this line node "%~dp0..\cli.js" start --projectRoot ../../../ pause exit
We are giving project root path to Metro instance here,
Or in
\node_modules\@react-native-community\cli\build\commands\runAndroid\runAndroid.js
edit this,const procConfig = { // delete this line cwd: scriptsDir // add this line cwd: process.cwd() };
We launched Metro launcher with working directory to our project root
The only way to run vanilla app is to update above workaround from our savior @nazreinkaram . Or, initiate using EXPO.
This worked for me even after upgrading to 0.59.2. Seems like a big issue with RN still
Metro server instance here is started by
runAndroid.js
if you ask forreact-native run-android
I can help you with android only, I am giving you fix on windows, if you are on Linux then I am sure you definitely know how to apply these fixes on your machine.
Problem is with Working Directory, Metro instance is launched with wrong working directory and no project root is passed inlaunchPackager
Threre are two fixes for this issue, apply only one of the belowUpdate
node_modules\react-native\scripts\launchPackager.bat
file.@echo off title Metro Bundler call .packager.bat // delete this line node "%~dp0..\cli.js" start Add this line node "%~dp0..\cli.js" start --projectRoot ../../../ pause exit
We are giving project root path to Metro instance here,
Or in
\node_modules\@react-native-community\cli\build\commands\runAndroid\runAndroid.js
edit this,const procConfig = { // delete this line cwd: scriptsDir // add this line cwd: process.cwd() };
We launched Metro launcher with working directory to our project root
The only way to run vanilla app is to update above workaround from our savior @nazreinkaram . Or, initiate using EXPO.
This worked for me even after upgrading to 0.59.2. Seems like a big issue with RN still
Did you imply that 0.59.2 still has this issue?
Here is what I did:
Haven't tried it with a brand new project, but the upgrade did not fix the error.
This was fixed for mac in 0.59.2, but not for windows yet.
For those using patch-package
, here some patch-file for having working development environment on Windows:
File patches/react-native+0.59.2.patch
:
diff --git a/node_modules/react-native/scripts/launchPackager.bat b/node_modules/react-native/scripts/launchPackager.bat
index d33f31e..377d1f7 100644
--- a/node_modules/react-native/scripts/launchPackager.bat
+++ b/node_modules/react-native/scripts/launchPackager.bat
@@ -6,6 +6,6 @@
@echo off
title Metro Bundler
call .packager.bat
-node "%~dp0..\cli.js" start
+node "%~dp0..\cli.js" --reactNativePath ../ --projectRoot ../../../ start
pause
exit
Maybe this is just me, but:
react-native start -- --reset-cache
returns
error Unexpected token <
Also, starting new project using
react-native init blablabla
and thencd blablabla
thenreact-native run-android
gives me the same error.
However, the error went away if I use expo.
you should run it in cmd . Not in vscode terminal
Created a new project in windows by using version 0.59.2, got the same issue.
Same issue here, when upgrading from 0.59.0 to 0.59.2 (OS: Windows 10, npm: 6.7.0).
The workaround from @nazreinkaram worked for us. More precisely, we have edited node_modules\@react-native-community\cli\build\commands\runAndroidrunAndroid.js and replaced
cwd: scriptsDir with cwd: process.cwd()
We hadn't reset the cache, deleted node_modules folder or tried anything else before applying this quick fix.
"dependencies": {
"react": "16.8.3",
"react-native": "0.59.2",
"react-native-camera": "^2.1.0",
"react-native-gesture-handler": "^1.1.0",
"react-native-qrcode-svg": "^5.1.2",
"react-native-svg": "^9.3.3",
"react-navigation": "^3.5.1"
},
"devDependencies": {
"@babel/core": "7.4.0",
"@babel/runtime": "7.4.2",
"babel-jest": "24.5.0",
"jest": "24.5.0",
"metro-react-native-babel-preset": "0.53.1",
"react-test-renderer": "16.8.3"
}
Metro server instance here is started by
runAndroid.js
if you ask forreact-native run-android
I can help you with android only, I am giving you fix on windows, if you are on Linux then I am sure you definitely know how to apply these fixes on your machine.
Problem is with Working Directory, Metro instance is launched with wrong working directory and no project root is passed inlaunchPackager
Threre are two fixes for this issue, apply only one of the belowUpdate
node_modules\react-native\scripts\launchPackager.bat
file.@echo off title Metro Bundler call .packager.bat // delete this line node "%~dp0..\cli.js" start Add this line node "%~dp0..\cli.js" start --projectRoot ../../../ pause exit
We are giving project root path to Metro instance here,
Or in
\node_modules\@react-native-community\cli\build\commands\runAndroid\runAndroid.js
edit this,const procConfig = { // delete this line cwd: scriptsDir // add this line cwd: process.cwd() };
We launched Metro launcher with working directory to our project root
Thanks a lot. It works for me
Thanks it worked for me as well. But this means for every new project i start, i must make this change to the runAndroid.js
I just only init new project with react-native init myapp
and have same issue :|
I think react-native version 0.59 have this problem :|
FYI, was having this issue too after upgrading from 0.57.2 to 0.59.1. The solution came from @FibreFoX who posted above showing the diff between 0.59.1 and 0.59.2.
Upgrading to 0.59.2 fixed the pathing and metro bundler works correctly once again.
GLORY! (Thank you @FibreFoX)
FYI, was having this issue too after upgrading from 0.57.2 to 0.59.1. The solution came from @FibreFoX who posted above showing the diff between 0.59.1 and 0.59.2.
Upgrading to 0.59.2 fixed the pathing and metro bundler works correctly once again.
GLORY! (Thank you @FibreFoX)
hmm. I tried this yesterday and the issue is still there. Let me run it again later today.
run
react-native start -- --reset-cache
then
react-native run-android
in separate command lineworks fine for me, maybe just for a temporary solution.
there is another solution from @nazreinkaram by updating
launchPackager.bat
, no need to open two cmd line. thanks
Works Fine!!!!
Open 3 windows (cmd prompt with admin privilegies) in the folder project.
emulator -no-snapshot -avd Nexus_5X_API_23 (Nexus is my emulator, wait open first to open others)
react-native start -- --reset-cache
react-native run-android
.'.ThankYou.'.
Metro server instance here is started by
runAndroid.js
if you ask forreact-native run-android
I can help you with android only, I am giving you fix on windows, if you are on Linux then I am sure you definitely know how to apply these fixes on your machine.
Problem is with Working Directory, Metro instance is launched with wrong working directory and no project root is passed in
launchPackager
Threre are two fixes for this issue, apply only one of the below
Update
node_modules\react-native\scripts\launchPackager.bat
file.@echo off title Metro Bundler call .packager.bat // delete this line node "%~dp0..\cli.js" start Add this line node "%~dp0..\cli.js" start --projectRoot ../../../ pause exit
We are giving project root path to Metro instance here,
Or in
\node_modules\@react-native-community\cli\build\commands\runAndroid\runAndroid.js
edit this,const procConfig = { // delete this line cwd: scriptsDir // add this line cwd: process.cwd() };
We launched Metro launcher with working directory to our project root
Thanks so much, been fighting this for some hours
Just Run With 'react-native start' In a Command line & run 'react-native run-android' in a another new command line .Then It will Work Fine.
@this error is happening for directory problem in nodemodules/react-native/script....
Metro server instance here is started by
runAndroid.js
if you ask forreact-native run-android
I can help you with android only, I am giving you fix on windows, if you are on Linux then I am sure you definitely know how to apply these fixes on your machine.
Problem is with Working Directory, Metro instance is launched with wrong working directory and no project root is passed in
launchPackager
Threre are two fixes for this issue, apply only one of the below
Update
node_modules\react-native\scripts\launchPackager.bat
file.@echo off title Metro Bundler call .packager.bat :: delete this line node "%~dp0..\cli.js" start :: Add this line node "%~dp0..\cli.js" start --projectRoot ../../../ pause exit
We are giving project root path to Metro instance here,
Or in
\node_modules\@react-native-community\cli\build\commands\runAndroid\runAndroid.js
edit this,const procConfig = { // delete this line cwd: scriptsDir // add this line cwd: process.cwd() };
We launched Metro launcher with working directory to our project root
it works for me thanks
react-native info
info
React Native Environment Info:
System:
OS: Windows 10
CPU: (4) x64 Intel(R) Core(TM) i3-5005U CPU @ 2.00GHz
Memory: 608.47 MB / 3.90 GB
Binaries:
Yarn: 1.12.1 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
npm: 6.7.0 - C:\Program Files\nodejs\npm.CMD
IDEs:
Android Studio: Version 3.1.0.0 AI-173.4720617
i can confirm this works and fixes the issue
run
react-native start -- --reset-cache
then
react-native run-android in separate command line
I have same issue , When I upgrade to 0.59.2 , I must always put --reset-cache
to start package
Updated status as of now, Using the newest version 0.59, I am able to fire up new vanillla project without error.
I got this problem few days ago. today after erasing node_modules it get back
I have metro.config.js as posted above
i tried :
// delete this line
// node "%~dp0..\cli.js" start
// Add this line
node "%~dp0..\cli.js" start --projectRoot ../../../
const procConfig = {
// delete this line
// cwd: scriptsDir
// add this line
cwd: process.cwd()
};
I give me this error now :
error: bundling failed: Error: Unable to resolve module `./utils/batch`
from `...node_modules\react-redux\lib\index.js`:
The module `./utils/batch` could not be found from `...node_modules\react-redux\lib\index.js`.
Indeed, none of these files exist:
"react-native": "0.59.2"
"react": "16.8.6"
"react-redux" : "6.0.1"
@alainib update to latest version
@alainib update to latest version
i tried ( failled completly )
"react": "16.8.6", "react-native": "0.59.5", "react-redux" : "7.0.2"
it finally worked thank you
"react": "16.8.3", "react-native": "0.59.2", "react-redux": "6.0.1"
node_modules\react-native\scripts\launchPackager.bat
as it with node "%~dp0..\cli.js" start
change @react-native-community\cli\build\commands\runAndroid\runAndroid.js
:
const procConfig = { cwd: process.cwd() }
npm cache clean --force
npm start --clear-cache
react-native start --reset-cache
C:\Users\YOURUSERNAME\AppData\Local\Temp\metro-cache
Thanks, @Souradeep-16
Just Run With 'react-native start' In a Command line & run 'react-native run-android' in another new command line .Then It will Work Fine.
@this error is happening for directory problem in nodemodules/react-native/script....
Metro server instance here is started by
runAndroid.js
if you ask forreact-native run-android
I can help you with android only, I am giving you fix on windows, if you are on Linux then I am sure you definitely know how to apply these fixes on your machine.
Problem is with Working Directory, Metro instance is launched with wrong working directory and no project root is passed inlaunchPackager
Threre are two fixes for this issue, apply only one of the belowUpdate
node_modules\react-native\scripts\launchPackager.bat
file.@echo off title Metro Bundler call .packager.bat // delete this line node "%~dp0..\cli.js" start Add this line node "%~dp0..\cli.js" start --projectRoot ../../../ pause exit
We are giving project root path to Metro instance here,
Or in
\node_modules\@react-native-community\cli\build\commands\runAndroid\runAndroid.js
edit this,const procConfig = { // delete this line cwd: scriptsDir // add this line cwd: process.cwd() };
We launched Metro launcher with working directory to our project root
The only way to run vanilla app is to update above workaround from our savior @nazreinkaram . Or, initiate using EXPO.
This worked for me even after upgrading to 0.59.2. Seems like a big issue with RN still
This worked for me for 0.59.0. However, is this fixed in a higher version of RN.
I tried upgrading to 0.59.0 faced the same issue, later upgraded to 0.59.9 solved this issue.
Using latest 0.59.10 - fresh project - moving App.js, app.json and index.js into a src folder. Setting projectRoot as src is ignored.
it looks it is permanently broken, only thing that temproray works is this https://github.com/facebook/react-native/issues/23908#issuecomment-473596547
i dont know how the error happened, i had some errors with iOS pods first, then i ran yarn install and also npm install (maybe mistake to run both but probably its not the reason), i even deleted problematic folder in ios pods, didnt help, then i ran lot of commands like rm -rf node_modules, npm install etc nothing helped then the error as stated by the thread starter happened. so something somewhere is still broken.
EDIT: updating
"react-native": "0.59.1",
to
"react-native": "0.59.10",
seems to fix the error.
Those steps except the last 2 fix the issue that arise after I installed exios lib.
radlew clean on android (cd android ; ./gradlew clean ; cd .. )
remove pods folder on ios and install again (cd ios ; pod install ; cd .. )
I think from RN version 0.59.0 you have to manually start the server
that is
run react-native start
And then open another terminal and then run
react-native run-android
previous version automatically starts the development server. But I think there is a change from RN 0.59.0 upwards.
The above was what worked for me
same issues
Error: Unable to resolve module
./index
from node_modules\react-native\scripts/.: The module
./indexcould not be found from
node_modules\react-native\scripts/.`React Native Environment Info:
System:
OS: Windows 10
CPU: (4) x64 Intel(R) Core(TM) i3-3110M CPU @ 2.40GHz
Memory: 569.59 MB / 3.89 GB
Binaries:
Yarn: 1.12.3 - C:\Users\Vivek\AppData\Roaming\npm\yarn.CMD
npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD
IDEs:
Android Studio: Version 3.3.0.0 AI-182.5107.16.33.5314842Environment :
"react": "16.8.3",
"react-moment": "^0.8.4"
Hey, were you able to solve it? I'm under the same issue :S
It's a liar. That file does indeed exist!
Since my React Native test runner is nested inside an examples directory of the main module repo. I have a .watchmanconfig
with the following.
{
"ignore_dirs": [
".git",
"node_modules",
"examples"
]
}
If you follow the recommendation to watchman watch-del
and watchman watch-project
, you'll pickup the .watchmanconfig
which stops watching examples
, etc. If you watch your nested project to run again, just don't do the watch-project
command after watch-del
ing.
I don't know if this causes other problems, but this is how I got my project working again:
watchman watch-del /Users/username/code/project/react-native-video/examples/MyExampleProject
and that's it! Don't watchman watch-project
.
Update:
Actually I'm back to square one. It broke again when I ran wml
to handle the puedo symlinking.
I updated to this
"metro-react-native-babel-preset": "0.54.1"
And started workinng again.
Just Run With 'react-native start' In a Command line & run 'react-native run-android' in a another new command line .Then It will Work Fine.
@this error is happening for directory problem in nodemodules/react-native/script....
I think from RN version 0.59.0 you have to manually start the server
that isrun react-native start
And then open another terminal and then run
react-native run-android
previous version automatically starts the development server. But I think there is a change from RN 0.59.0 upwards.
The above was what worked for me
So with the release of 0.59, the debugging process of an RN app is even more painful than it already was?
What a load of crap this development platform is. I can't believe it even exists, let alone the morons who choose it for their projects. I have no choice, I'm stuck with existing projects that I have to support.
Compare it with Xamarin: To debug in either platform, you press the Play button. That's it.
For some reason, none of these worked for me.
At the brink of insanity, I just created an index.android.js
file at the root of my folder and it started to work again
Hoping to find a better solution...
I got the same issue when I updated my app react-native version. I deleted the node_modules file and ran the npm install
command again to reinstall all the modules and the error went away.
For some reason, none of these worked for me.
At the brink of insanity, I just created anindex.android.js
file at the root of my folder and it started to work againHoping to find a better solution...
This worked for me.
I had put my hook useDispatch outside of my function component... maybe it can help someone
For some reason, none of these worked for me.
At the brink of insanity, I just created anindex.android.js
file at the root of my folder and it started to work againHoping to find a better solution...
Was only getting this issue on android, I had changed my entry file in app/build.gradle
suspected that might be it. Added an index.android.js
to my root and imported my actual files (./src) and it works.
System:
OS: Windows 10 10.0.18363
CPU: (16) x64 AMD Ryzen 7 3700X 8-Core Processor
Memory: 16.09 GB / 31.95 GB
Binaries:
Node: 12.16.1 - C:\Users\ryoid\scoop\apps\nvm\current\nodejs\nodejs\node.EXE
Yarn: 1.22.0 - C:\Users\ryoid\scoop\apps\nvm\current\nodejs\nodejs\yarn.CMD
npm: 6.13.4 - C:\Users\ryoid\scoop\apps\nvm\current\nodejs\nodejs\npm.CMD
SDKs:
Android SDK:
API Levels: 28, 29
Build Tools: 28.0.3, 29.0.2
System Images: android-25 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.5 => 0.61.5
Most helpful comment
run
react-native start -- --reset-cache
then
react-native run-android
in separate command lineworks fine for me, maybe just for a temporary solution.
there is another solution from @nazreinkaram by updating
launchPackager.bat
, no need to open two cmd line. thanks