React Native version: 0.61
I followed following link to get started with react-native
Getting started with react native
I tried to create native app without expo so i as per documentation i followed following command
Initial commands
npm install -g react-native-cli
react-native init AwesomeProject
After run android command
react-native run-android
It gave me following error on emulator
enter image description here
So i used start command to run metro server
react-native start
This command gave me another error in console
Snack, code example, screenshot, or link to a repository:
Describe what you expected to happen:
Was expecting it to bypass command successfully and app to run on android
Thanks for submitting your issue. Can you take another look at your description and make sure the issue template has been filled in its entirety?
馃憠 Click here if you want to take another look at the Bug Report issue template.
Node : v12.11.0
Npm: 6.11.3
Python: 2.7.16
Try to downgrade your Node version.
I've had the same issue after I upgraded from v12.8 => v12.11
After the downgrade it works again
I downgrade Node version from 12.11.10 to the last stable version 10.16.3 LTS and it worked for me.
Thanks @NyauIf
yes i am also facing this issues. actually Node.js Recommended For Most Users is version 10.16.3 LTS.
Using below choco command will install Latest version of 12.11.0.
choco install -y nodejs.install python2 jdk8
I downgrade Node version from 12.11.0 to 10.16.3 LTS and it worked for me.
Just downgrade the Node version it will work fine.
Best way to use https://github.com/nvm-sh/nvm
it helps to change the node version as required,
Same problem here. The following fixed it:
choco uninstall nodejs
choco install nodejs-lts
I downgrade Node version:
choco install -y nodejs.install --version 10.16.3 --force
downgrading Node version worked for me.
Thanks everyone for help.
They should be working on compatibility with node 12 though, the 10.16.3 LTS node is going to be replaced by Node 12 in Oct. 22, 2019.
This issue should be reopened - following the documentation correctly leads to this failure, which means this is an open problem
12.8 works for the time being - separate issue #26808 opened about the same problem
choco uninstall nodejs
choco install nodejs --version 12.8
Actually, the version 12.10.0 is the latest that works. Still, the regex is incorrect nonetheless, and the newer versions of node won't tolerate it anymore, so it needs to be fixed.
It won't affect older versions, but surely will enable to be used in newer ones.
i had same problem:
react-native start
has error
Invalid regular expression
and after running react-native run-android
my android device show me
unable to load script. make sure you...
then I tried to run choco unistall nodejd
and run choco install nodejs-lts
but react-native star
t has that error). so I run react-native info
and result is:
info Fetching system and libraries information...
System:
OS: Windows 7
CPU: (8) x64 Intel(R) Core(TM) i7 CPU Q 740 @ 1.73GHz
Memory: 925.38 MB / 3.98 GB
Binaries:
Node: 12.11.1 - C:Program Files\nodejs\node.EXE
npm: 6.11.3 - C:Program Files\nodejsnpm.CMD
SDKs:
Android SDK:
API Levels: 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
Build Tools: 25.0.0, 25.0.3, 26.0.0, 26.0.1, 26.0.2, 26.0.3, 27.0.3, 28.0.
1, 28.0.2, 28.0.3, 29.0.1, 29.0.2
System Images: android-25 | Google APIs Intel x86 Atom, android-28 | Googl
e APIs Intel x86 Atom_64
npmPackages:
react: 16.9.0 => 16.9.0
react-native: 0.61.2 => 0.61.2
I could not find my answer.
Hello everyone. I had the same problem and this is what I did to solve it thanks to @NyauIf :
choco uninstall nodejs.install
choco install nodejs-lts
cd project && react-native start
Having the issue with the new lts version so previous fixes will no longer work (as with the current latest 13.0.0) . As halkliff said, the lts version is now changed to 12.13.0. Can get it to work if you get 10.16.3 from https://nodejs.org/dist/
Actually, the version 12.10.0 is the latest that works. Still, the regex is incorrect nonetheless, and the newer versions of node won't tolerate it anymore, so it needs to be fixed.
It won't affect older versions, but surely will enable to be used in newer ones.
Nodejs 12.13.0 still will cause this issue.
Hey, as stated above with the release of Node 13 this had made the LTS now 12.13.0.
You can revert back to 12.9.1
and this works as intended.
Is there a plan on this being fixed for the latest versions of Node?
+1 on re-open, especially considering that the current LTS demonstrates this issue.
As @JasonHughes94 mentioned, node 12.9.1
seems to be most recent version which does not demonstrate this error. Direct downloads for 12.9.1 can be found here: https://nodejs.org/download/release/v12.9.1/
If you're using chocolatey, you can explicitly install this version with the following:
choco install nodejs.install --version=12.9.1
Since this ticket seems to have the most history and context, I think we could reopen this one and close the following:
This should be resolved once https://github.com/facebook/metro/pull/464/files is landed and RN is updated to point to the latest.
It appears in node_modules\metro-config\src\defaultsblacklist.js, there is an invalid regular expression that needed changed. I changed the first expression under sharedBlacklist from:
var sharedBlacklist = [
/node_modules[/\]react[/\]dist[/\]./,
/website/node_modules/./,
/heapCapture/bundle.js/,
/./__tests__/./
];
to:
var sharedBlacklist = [
/node_modules[/\]react[/\]dist[/\]./,
/website/node_modules/./,
/heapCapture/bundle.js/,
/./__tests__/./
];
@armohammadi56 - After trying to spot the difference of the two code blocks for 2 minutes, I decided to throw them into text files and git diff --no-index
them. Turned out there are no differences. 馃槀
Looks like you accidentally copy+pasted the same. Can you edit your comment?
This issue has been fixed as of #468 in metro.
Now instead of editing /node_modules you can add resolutions
for metro-config in package.json
as temporary workaround:
"resolutions": {
"metro-config": "0.57.0"
},
I've downgraded to latest stable release 12.13.0, added resolutions
section in package.json
, runned npm install
and still got the regex error.
@8bitpravibyte Try to remove node_modules
and install it again or maybe try to use yarn
instead of npm i
@EugeneDraitsev Thanks man, it worked.
I've deleted node_modules
which were in C:\Users\Test\AppData\Roaming\npm\node_modules\react-native
, because in my error the path for the blacklist.js file was this, installed react-native-cli
again and used yarn
to install them again.
React native setup is painful on win .... i have stuck for 1 day for this problem.
Can you explain why this is a problem though?
For the record I'm still getting it after doing everything suggested in this thread running on Windows 10.
error Invalid regular expression: /(.\__fixtures__\.|node_modules[\]react[\]dist[\].|website\node_modules\.
*|heapCapture\bundle.js|.\__tests__\.*)$/: Unterminated character class. Run CLI with --verbose flag for more detai
ls.
@ahaq0 I am on Windows 10, what I did is the following:
1) react-native init appName --version="0.60.0"
2) open windows explorer and find this path in your app dir node_modules\metro-config\src\defaults
there you will see blacklist.js
, you can open it and edit the sharedBlacklist variable (array with regexs) by removing all /
(forward slash symbol) which are not in the begging or in the end of a row (if there are 4-5 rows of regex, you should leave there only the first and last forward slashes)
3) open another terminal window and cd into the dir (appName) then react-native start
(to start a metro server)
4) cd appName && react-native run-android
in the first terminal window
Hi, i have the same problem when i execute
react-native start
I tried to follow the steps but i have a problem when i uninstall with choco!
1潞 C:\WINDOWS\system32> node -v
=> v12.13.0
2潞 choco uninstall nodejs
Uninstalling the following packages:
nodejs
nodejs is not installed. Cannot uninstall a non-existent package.
How can is possible??? What can i do to uninstall and re-install?
Thanks!
You can manually uninstall it using the Control Panel
in Windows
and download whatever you want.
You can manually uninstall it using the
Control Panel
inWindows
and download whatever you want.
Thanks!. Done and working
The mention of this fix should reach - http://facebook.github.io/react-native/docs/troubleshooting#content
Simplest steps to fix this for me were:
yarn install
Now instead of editing /node_modules you can add
resolutions
for metro-config inpackage.json
as temporary workaround:"resolutions": { "metro-config": "0.57.0" },
Thank you, this worked for me.
It's too bad the metro devs were not aware of this issue in time but it's nice Yarn offers options to work around this semi-cleanly.
Take a look at this hope this works for you:
https://stackoverflow.com/questions/55441230/unable-to-load-script-make-sure-you-are-either-running-a-metro-server-or-that-yo?newreg=834f28d14a0f4de0b6928f6c875beeaf
Go to this file: node_modules\metro-config\src\defaultsblacklist.js and change this code:
var sharedBlacklist = [
/node_modules[/\]react[/\]dist[/\]./,
/website/node_modules/./,
/heapCapture/bundle.js/,
/./__tests__/./
];
and change to this:
var sharedBlacklist = [
/node_modules[/\]react[/\]dist[/\]./,
/website/node_modules/./,
/heapCapture/bundle.js/,
/./__tests__/./
];
This worked for me!!
It's still not fixed, why it's closed?
This is still very much an issue and should be reopened.
It's still not fixed
yes i am also facing this issues. actually Node.js Recommended For Most Users is version 10.16.3 LTS.
Using below choco command will install Latest version of 12.11.0.
choco install -y nodejs.install python2 jdk8I downgrade Node version from 12.11.0 to 10.16.3 LTS and it worked for me.
It worked for me, thanks for the solution.
@smakhtin @BrandonBlanchard @Rananjaya I can advise you to read the topic. It is fixed and at some point the fix will land in your env. I agree it should have been fixed before it broke but these things happen. Metro devs are human just like the rest of us (I assume 馃槈).
https://github.com/facebook/react-native/issues/26598#issuecomment-548912483
I'm getting the same problem here.
It appears in node_modules\metro-config\src\defaultsblacklist.js, there is an invalid regular expression that needed changed. I changed the first expression under sharedBlacklist from:
var sharedBlacklist = [
/node_modules[/]react[/]dist[/]._/, /website/node_modules/._/,
/heapCapture/bundle.js/,
/._/tests/._/
];to:
var sharedBlacklist = [
/node_modules[/]react[/]dist[/]._/, /website/node_modules/._/,
/heapCapture/bundle.js/,
/._/tests/._/
];
This work for me as well, but I have to change the express a bit:
var sharedBlacklist = [
/node_modules[\]react[\]dist[\]./,
/website/node_modules/./,
/heapCapture/bundle.js/,
/./__tests__/./
];
I am on Windows 10, and using Anaconda.
+1 on re-open, especially considering that the current LTS demonstrates this issue.
As @JasonHughes94 mentioned, node
12.9.1
seems to be most recent version which does _not_ demonstrate this error. Direct downloads for 12.9.1 can be found here: https://nodejs.org/download/release/v12.9.1/If you're using chocolatey, you can explicitly install this version with the following:
choco install nodejs.install --version=12.9.1
Since this ticket seems to have the most history and context, I think we could reopen this one and close the following:
26975
26969
26878
26829
26808
This should be resolved once https://github.com/facebook/metro/pull/464/files is landed and RN is updated to point to the latest.
Only solution that worked for me was to downgrade node to the version of 12.9.1.
Thanks! :)
The solution * uninstall react native and move to an actual stable platform.
This sucks..!!!
Setting it up to 12.9.1 worked
@ahaq0 I am on Windows 10, what I did is the following:
react-native init appName --version="0.60.0"
- open windows explorer and find this path in your app dir
node_modules\metro-config\src\defaults
there you will seeblacklist.js
, you can open it and edit the sharedBlacklist variable (array with regexs) by removing all/
(forward slash symbol) which are not in the begging or in the end of a row (if there are 4-5 rows of regex, you should leave there only the first and last forward slashes)- open another terminal window and cd into the dir (appName) then
react-native start
(to start a metro server)cd appName && react-native run-android
in the first terminal window
changing blacklist.js file for '/' slashes is temporary solution. after adding new dependency or 'npm install' or 'yarn add' commands you have to do it again.
I listen advives to downgrade nodeJS to 10.16.3 maybe 12.9.1 also works.( uninstall nodejs choco uninstall or windows program uninstall page, download versions from here whichever you want to try. ). I also init new project with optin --version="0.60.0" maybe just that worked for me. for my old projects I dont know what to do.
I want permanent solution with a nodejs LTS release.
choco install nodejs.install --version=12.9.1
This worked for me.
Instead of changing node version globally, I found "nodist" a better option for changing versions specific to projects.
nodist local 12.9.1
will do the magic
I solved the issue refer this https://iamsapankumar.blogspot.com/2019/10/error-invalid-regular-expression.html?m=1&fbclid=IwAR24kM7FvVFPR9ZTdq6HAmFDvF-Th7MnV2IvS3Yo_F9m6snDFh_QNsr0vgs
This worked perfectly, thank you !
I solved the issue refer this https://iamsapankumar.blogspot.com/2019/10/error-invalid-regular-expression.html?m=1&fbclid=IwAR24kM7FvVFPR9ZTdq6HAmFDvF-Th7MnV2IvS3Yo_F9m6snDFh_QNsr0vgs
Worked for me too, thanks.
Downgrading to nodejs 10.18.1 did it for me.
downgraded to 12.9.1, via windows uninstall and getting a previous version from here: https://nodejs.org/download/release/v12.9.1/
Terrible bug...
Downgrading is not an option if you really care for security. Believe or not, but sometimes newer versions of Node.js are fixing issues you should be concerned about.
Is anyone capable of providing insights on why there is an invalid regular expression or why at least some parser isn't capable of adopting newer capabilities of distinguishing a forward slash inside a character class from a terminating forward slash? Please, provide details on why there are no upgrades for either involved dependency and why no one's caring on behalf of this project. Eventually this is just proving how error-prone this npm-style of coding is: don't use deps without checking whether they are implemented well enough for your tool. This ain't Lego. According to this thread I sincerely doubt react-native was ever made for lasting long enough to become a favourable platform for software meant to have its own LTS versions ...
Don't downgrade. Otherwise consider downgrading to Windows XP or macOS 9 as well whenever your website does not look any good no more.
Still hapenning with Node LTS 12.16.2, this should be fixed ASAP...
None of the above solutions worked for me.
So I deleted node from control panel and then install downgraded version
choco install nodejs --version 12.8
Now it is working.
A Fix should already be implemented https://github.com/facebook/metro/pull/468
Downgrading is not an option if you really care for security. Believe or not, but sometimes newer versions of Node.js are fixing issues you should be concerned about.
Well you can try to upgreade to the newest Metro version, stop working or downgrade Node.Js.
Its not like your App uses Node.Js
Well you can try to upgreade to the newest Metro version, stop working or downgrade Node.Js.
Its not like your App uses Node.Js
I'm pretty aware of Node.js not involved in running my app, but it is essential to processing several 100.000+ files for building it. Do you trust all the modules involved in building your application for they are provided by a plethora of different vendors? Do you expect all those files to be free of any vulnerability at any time? Do you believe that neither such vulnerability at build time could affect your application's integrity at runtime?
@soletan If the fix is upstream we can only wait for the release or run straight from the repo. I do agree this fix could have been done a while ago.
For me changing the code into node_modules\metro-config\src\defaults\blacklist.js
as per following worked.
var sharedBlacklist = [
//node_modules[/\]react[/\]dist[/\]./,
//website/node_modules/./,
//heapCapture/bundle.js/,
//./tests/./
];
@ThaJay @zaidpathanGit @soletan
Just update metro-react-native-babel-preset
to latest 0.59.0
version and issue will be fixed.
I'm on latest NodeJS 12.18.0
and react-native 0.62.2
@ThaJay @zaidpathanGit @soletan
Just updatemetro-react-native-babel-preset
to latest0.59.0
version and issue will be fixed.
I'm on latestNodeJS 12.18.0
and react-native0.62.2
This worked for me. I updated metro-react-native-babel-preset from 0.51.1 to 0.59.0, and i am using react-native version 0.61.3. npm install and audit fix if needed.
I have this issue. I tried to run the app using different node versions by upgrading and downgrading node but none of them worked.
I get Unhandled JS Exception: Invalid regular expression: Invalid group specifier name.
Any help would be great
Spent a day looking at this, for me nothing mentioned above helped, I checked all packages for upgraded and it turned out to be an issue with 'validator' package, see this issue: https://github.com/validatorjs/validator.js/issues/1354
Edit: also I should say that in debug it was all fine, however as soon as I built in release mode and deployed on a device, I got this error.
Validator issue mentioned was fixed long ago from our end; let me know if you are still blocked on this.
This should be fixed
I get this error on following the react-360 introductory steps.
Invalid regular expression: /(node_modules[\]react[\]dist[\].|website\node_modules\.|heapCapture\bundle.js|.\__tests__\.)$/: Unterminated character class
Node version 12.18.4.
Doesn't instill confidence when you can't run the default app supplied for an example.
@Mitchell-Stone -- can you post a bit detailed error log?
@profnandaa
I found that changing the blacklist var worked:
var sharedBlacklist = [
/node_modules[\/\\]react[\/\\]dist[\/\\].*/,
/website\/node_modules\/.*/,
/heapCapture\/bundle\.js/,
/.*\/__tests__\/.*/
];
I did this in the metro-config file
Most helpful comment
Try to downgrade your Node version.
I've had the same issue after I upgraded from v12.8 => v12.11
After the downgrade it works again