-
Notifications
You must be signed in to change notification settings - Fork 24.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
react-native start giving Invalid regular expression invalid error #26598
Comments
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 |
Try to downgrade your Node version. |
I downgrade Node version from 12.11.10 to the last stable version 10.16.3 LTS and it worked for me. |
yes i am also facing this issues. actually Node.js Recommended For Most Users is version 10.16.3 LTS. 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. |
Same problem here. The following fixed it:
|
I downgrade Node version: |
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
|
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:
and after running
then I tried to run
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 :
|
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/ |
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. 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 If you're using chocolatey, you can explicitly install this version with the following:
Since this ticket seems to have the most history and context, I think we could reopen this one and close the following: #26975 This should be resolved once https://github.com/facebook/metro/pull/464/files is landed and RN is updated to point to the latest. |
Setting it up to 12.9.1 worked |
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. |
This worked for me. |
Instead of changing node version globally, I found "nodist" a better option for changing versions specific to projects.
|
This worked perfectly, thank you ! |
Summary: **Summary** On Windows with Node.js v12.x.x, Metro crashes with ``` SyntaxError: Invalid regular expression: /(.*\\__fixtures__\\.*|node_modules[\\\]react[\\\]dist[\\\].*|website\\node_modules\\.*|heapCapture\\bundle\.js|.*\\__tests__\\.*)$/: Unterminated character class ``` This has been reported in #453, facebook/react-native#26829, facebook/react-native#26969, facebook/react-native#26878, facebook/react-native#26598, expo/expo-cli#1147 and expo/expo-cli#1074. There are a few open pull requests attempting to fix this same issue: * #464 * #461 * #458 * #454 However, none of the existing PRs address the *root cause* of this error: the `escapeRegExp` function in `blacklist.js` tries to convert regular expressions to be agnostic to the path separator ("/" or "\\"), but turns some valid regular expressions to invalid syntax. The error was is this line: https://github.com/facebook/metro/blob/142348f5345e40ce2075fc7f9dfa30c5d31fee2a/packages/metro-config/src/defaults/blacklist.js#L28 When given a regular expression, such as `/node_modules[/\\]react[/\\]dist[/\\].*/`, on Windows where `path.sep` is `\` (which is also an escape character in regular expressions), this gets turned into `/node_modules[\\\]react[\\\]dist[\\\].*/`, resulting in the `Unterminated character class` error. Automatically replacing `[/]` with `[\]` is an error, as is replacing `[\/]` with `[\\]`, because in both of these cases the backslash before the end of character class "]" escapes it, and the character class becomes unterminated. Therefore, this PR changes the code to look for both escaped forward slash `\/` and forward slash `/`, and always replace them with the escaped version (`\/` or `\\`, depending on the platform). This fixes #453. **Test plan** Added a test case that exercises the code with both `\` and `/` as path separators. Pull Request resolved: #468 Differential Revision: D18201730 Pulled By: cpojer fbshipit-source-id: 6bb694178314c39d4d6a0fd9f8547bfa2c36f894
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/ |
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 Now it is working. |
A Fix should already be implemented facebook/metro#468
Well you can try to upgreade to the newest Metro version, stop working or downgrade 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
|
@ThaJay @zaidpathanGit @soletan |
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: validatorjs/validator.js#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 did this in the metro-config file |
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
Steps To Reproduce
Initial commands
After run android command
It gave me following error on emulator
enter image description here
So i used start command to run metro server
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
The text was updated successfully, but these errors were encountered: