Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Expo fails to start the project: error Invalid regular expression: /(.*\\__fixtures__ #1074

Closed
4erem6a opened this issue Oct 5, 2019 · 49 comments
Assignees

Comments

@4erem6a
Copy link

4erem6a commented Oct 5, 2019

Description

I just initialize a new expo project and try to start it, but every time I get this error. This also happens with all my expo projects on this machine.

Expected Behavior

I use yarn start and expect expo to start the project.

Observed Behavior

PS E:\Projects\test> $env:expo_debug = 'true'
PS E:\Projects\test> yarn start
yarn run v1.19.0
$ expo start
Starting project at E:\Projects\test
Expo DevTools is running at http://localhost:19002
Opening DevTools in the browser... (press shift-d to disable)
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 details.

Metro Bundler process exited with code 1
Error: Metro Bundler process exited with code 1
    at ChildProcess.<anonymous> (C:\@expo\xdl@56.2.7\src\Project.ts:1804:16)
    at Object.onceWrapper (events.js:300:26)
    at ChildProcess.emit (events.js:210:5)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Environment

  Expo CLI 3.2.3 environment info:
    System:
      OS: Windows 10
    Binaries:
      Yarn: 1.19.0 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
      npm: 6.11.3 - C:\Program Files\nodejs\npm.CMD
    IDEs:
      Android Studio: Version  3.4.0.0 AI-183.6156.11.34.5522156
@ghost
Copy link

ghost commented Oct 7, 2019

same here

@ghost
Copy link

ghost commented Oct 7, 2019

Fixed it by downgrading Node version

@IanSaucy
Copy link

IanSaucy commented Oct 9, 2019

@yuraheiko From what version and to what version of node did you downgrade?

@painkkiller
Copy link

same here

@ghost
Copy link

ghost commented Oct 9, 2019

@yuraheiko From what version and to what version of node did you downgrade?

I dont remember which version I had, but for me works node 10 LTS.

@GollyJer
Copy link

GollyJer commented Oct 12, 2019

Just updated to Node 12.12.0 and got this error. ☹
(Using Windows 10)

@GollyJer
Copy link

GollyJer commented Oct 12, 2019

Tried
12.11 👎
12.10 👎
12.9 👍 ✔

Using expo-cli 3.3.0.

@kundankumarr
Copy link

i just start react native using expo cli .. and get this error and im confused..
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 details.

Metro Bundler process exited with code 1
Set EXPO_DEBUG=true in your env to view the stack trace.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ start: expo start
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\user\AppData\Roaming\npm-cache_logs\2019-10-12T13_00_57_090Z-debug.log

@frazermg
Copy link

I had this error too, downgraded to 10.16.3 and it's working.

@ocharlespereira
Copy link

Qual o comando que vcs usam para voltar versão sem dar erro?

usei o comando cinst nodejs.install --force -version 12.9 -allow-downgrade e não obtive sucesso, está dando erro

Failures

  • -allow-downgrade - -allow-downgrade not installed. The package was not found with the source(s) listed.
    Source(s): 'https://chocolatey.org/api/v2/'
    NOTE: When you specify explicit sources, it overrides default sources.
    If the package version is a prerelease and you didn't specify --pre,
    the package may not be found.
    Please see https://chocolatey.org/docs/troubleshooting for more
    assistance.
  • -version - -version not installed. The package was not found with the source(s) listed.
    Source(s): 'https://chocolatey.org/api/v2/'
    NOTE: When you specify explicit sources, it overrides default sources.
    If the package version is a prerelease and you didn't specify --pre,
    the package may not be found.
    Please see https://chocolatey.org/docs/troubleshooting for more
    assistance.
  • 12.9 - 12.9 not installed. The package was not found with the source(s) listed.
    Source(s): 'https://chocolatey.org/api/v2/'
    NOTE: When you specify explicit sources, it overrides default sources.
    If the package version is a prerelease and you didn't specify --pre,
    the package may not be found.
    Please see https://chocolatey.org/docs/troubleshooting for more
    assistance.

@ocharlespereira
Copy link

ocharlespereira commented Oct 13, 2019

What command do you use to get back to the version without error?

cinst nodejs.install --force -version 12.9 -allow-downgrade and unsuccessful, is giving error...

image

@lanort
Copy link

lanort commented Oct 15, 2019

I had the node v12.12.0 (just recently via choco install nodejs) installed and got the following error:

C:\Users\alexa\jj>expo start
Starting project at C:\Users\alexa\jj
Expo DevTools is running at http://localhost:19002
Opening DevTools in the browser... (press shift-d to disable)
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 details.

Metro Bundler process exited with code 1
Set EXPO_DEBUG=true in your env to view the stack trace.

This downgrade fixed that:

choco uninstall nodejs
choco install nodejs --version=12.9.1

image

@Aleladeia99
Copy link

how can I uninstall nodejs with npm?

@umairbabar1995
Copy link

umairbabar1995 commented Oct 20, 2019

Just updated to Node 12.12.0 and got this error. ☹
(Using Windows 10)
removed Node 12.12.0 and install Node 10 LTS now its working

@bgohsman
Copy link

Thank you! I had everything working on my MacBook Pro and my Windows 10 laptop but could not, for the life of me, get things working on my desktop Windows 10 machine. Sure enough, choco installed the LTS version, which was 12.12.0 by that time. Uninstalled it and went back to the newest 10.x and everyone is happy again.

@hadessama1994
Copy link

Got this issue today on windows, but don't need to downgrade node, just as discussed on stackoverflow just need to change some hashes on your project:

\node_modules\metro-config\src\defaults\blacklist.js

var sharedBlacklist = [
  /node_modules[/\\]react[/\\]dist[/\\].*/,
  /website\/node_modules\/.*/,
  /heapCapture\/bundle\.js/,
  /.*\/__tests__\/.*/
];

change to:

var sharedBlacklist = [
  /node_modules[\/\\]react[\/\\]dist[\/\\].*/,
  /website\/node_modules\/.*/,
  /heapCapture\/bundle\.js/,
  /.*\/__tests__\/.*/
];

Hope it works like worked for me :)

@tkud04
Copy link

tkud04 commented Oct 26, 2019

Thank you @hadessama1994! Changing the value of the sharedBlackList variable in metro config src worked for me on windows 10. Just downloaded node 12.13.0 and did not have to downgrade.

@djsing
Copy link

djsing commented Oct 27, 2019

@hadessama1994 This worked for me too. To think a single character escape is the issue xD.

@JJader
Copy link

JJader commented Oct 27, 2019

@hadessama1994 Muito obrigado companheiro !!

@ahmostafa91
Copy link

Got this issue today on windows, but don't need to downgrade node, just as discussed on stackoverflow just need to change some hashes on your project:

\node_modules\metro-config\src\defaults\blacklist.js

var sharedBlacklist = [
  /node_modules[/\\]react[/\\]dist[/\\].*/,
  /website\/node_modules\/.*/,
  /heapCapture\/bundle\.js/,
  /.*\/__tests__\/.*/
];

change to:

var sharedBlacklist = [
  /node_modules[\/\\]react[\/\\]dist[\/\\].*/,
  /website\/node_modules\/.*/,
  /heapCapture\/bundle\.js/,
  /.*\/__tests__\/.*/
];

Hope it works like worked for me :)

Thank's a lot , it works for me

@osix
Copy link

osix commented Oct 28, 2019

Got this issue today on windows, but don't need to downgrade node, just as discussed on stackoverflow just need to change some hashes on your project:

\node_modules\metro-config\src\defaults\blacklist.js

var sharedBlacklist = [
  /node_modules[/\\]react[/\\]dist[/\\].*/,
  /website\/node_modules\/.*/,
  /heapCapture\/bundle\.js/,
  /.*\/__tests__\/.*/
];

change to:

var sharedBlacklist = [
  /node_modules[\/\\]react[\/\\]dist[\/\\].*/,
  /website\/node_modules\/.*/,
  /heapCapture\/bundle\.js/,
  /.*\/__tests__\/.*/
];

Hope it works like worked for me :)

It's more a crutch rather than a good solution. It will work until the metro-config is updated.
I have the same issue and I've downgraded to the node version 12.9.1. Only that really helped. Thanks to @GollyJer

facebook-github-bot pushed a commit to facebook/metro that referenced this issue Oct 29, 2019
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
@dharmveer97
Copy link

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 details.

Metro Bundler process exited with code 1

@realka
Copy link

realka commented Nov 2, 2019

Got this issue today on windows, but don't need to downgrade node, just as discussed on stackoverflow just need to change some hashes on your project:

\node_modules\metro-config\src\defaults\blacklist.js

var sharedBlacklist = [
  /node_modules[/\\]react[/\\]dist[/\\].*/,
  /website\/node_modules\/.*/,
  /heapCapture\/bundle\.js/,
  /.*\/__tests__\/.*/
];

change to:

var sharedBlacklist = [
  /node_modules[\/\\]react[\/\\]dist[\/\\].*/,
  /website\/node_modules\/.*/,
  /heapCapture\/bundle\.js/,
  /.*\/__tests__\/.*/
];

Hope it works like worked for me :)

Thanks worked! :)

@sece15
Copy link

sece15 commented Nov 3, 2019

#1074 (comment)
muchas gracias funciona perfectamente

@bonur
Copy link

bonur commented Nov 4, 2019

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 details.

Metro Bundler process exited with code 1

Same for me. I did 'fix' blacklist.js

@emiliano249
Copy link

#1074 (comment)

It Works for me on Windows 7 Ultimate. Thank You!!!

@rustyonrampage
Copy link

Got this issue today on windows, but don't need to downgrade node, just as discussed on stackoverflow just need to change some hashes on your project:

\node_modules\metro-config\src\defaults\blacklist.js

var sharedBlacklist = [
  /node_modules[/\\]react[/\\]dist[/\\].*/,
  /website\/node_modules\/.*/,
  /heapCapture\/bundle\.js/,
  /.*\/__tests__\/.*/
];

change to:

var sharedBlacklist = [
  /node_modules[\/\\]react[\/\\]dist[\/\\].*/,
  /website\/node_modules\/.*/,
  /heapCapture\/bundle\.js/,
  /.*\/__tests__\/.*/
];

Hope it works like worked for me :)

It works. But everytime I add a new package, it has to be done again. Annoying...

@deadmann
Copy link

deadmann commented Nov 9, 2019

Got this issue today on windows, but don't need to downgrade node, just as discussed on stackoverflow just need to change some hashes on your project:

\node_modules\metro-config\src\defaults\blacklist.js

var sharedBlacklist = [
  /node_modules[/\\]react[/\\]dist[/\\].*/,
  /website\/node_modules\/.*/,
  /heapCapture\/bundle\.js/,
  /.*\/__tests__\/.*/
];

change to:

var sharedBlacklist = [
  /node_modules[\/\\]react[\/\\]dist[\/\\].*/,
  /website\/node_modules\/.*/,
  /heapCapture\/bundle\.js/,
  /.*\/__tests__\/.*/
];

Hope it works like worked for me :)

It works. But everytime I add a new package, it has to be done again. Annoying...

Not For me:

E:\Hassan\ReactTutorial\rn-first-app>npm start

@ start E:\Hassan\ReactTutorial\rn-first-app
expo start

\Starting project at E:\Hassan\ReactTutorial\rn-first-app
Expo DevTools is running at http://localhost:19002
Opening DevTools in the browser... (press shift-d to disable)
error Unexpected token 'function'. Run CLI with --verbose flag for more details.

Metro Bundler process exited with code 1
Set EXPO_DEBUG=true in your env to view the stack trace.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ start: expo start
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Hassan\AppData\Roaming\npm-cache_logs\2019-11-09T10_08_29_028Z-debug.log

E:\Hassan\ReactTutorial\rn-first-app>

@fson
Copy link
Contributor

fson commented Nov 13, 2019

The underlying Metro issue has been fixed upstream in facebook/metro@7c6f30b.

@fson fson changed the title Expo fails to start the project Expo fails to start the project: error Invalid regular expression: /(.*\\__fixtures__ Nov 13, 2019
@dotjsNet
Copy link

Install Nodejs node-v10.15.3 it should resolve the issue.

@mmarcwabo
Copy link

Had the same problem (with nodejs 12.13.0).
My problem has been solved by both unistalling the 12.13 version and downgrade it to 12.9

@tim92109
Copy link

Another confirmation that the fix to blacklist.js worked. I CRINGE every time I'm prompted to update expo-cli. Unlike every other package I use, it's never simple and/or flawless.

@brentvatne
Copy link
Member

brentvatne commented Nov 18, 2019

@tim92109 - in this case the error that you appear to be encountering is not actually from expo-cli but from tools that underly it: node and metro (the react-native packager). as you can see from this stackoverflow post this error happens on any react-native project. further, the maintainer of expo-cli (@fson) actually went and fixed the bug in metro itself (facebook/metro@7c6f30b), which he does not maintain. so i don't think it's really fair to blame expo-cli here.

@nzrubin
Copy link

nzrubin commented Nov 21, 2019

Have the latest node JS 13.1.0 but same error
Great Thanks!
adjusting as advised above
\node_modules\metro-config\src\defaults\blacklist.js
worked for me
W10 Node 13.1.0

@emiliano249
Copy link

emiliano249 commented Nov 21, 2019 via email

@lucaslucenagithub
Copy link

Got this issue today on windows, but don't need to downgrade node, just as discussed on stackoverflow just need to change some hashes on your project:

\node_modules\metro-config\src\defaults\blacklist.js

var sharedBlacklist = [
  /node_modules[/\\]react[/\\]dist[/\\].*/,
  /website\/node_modules\/.*/,
  /heapCapture\/bundle\.js/,
  /.*\/__tests__\/.*/
];

change to:

var sharedBlacklist = [
  /node_modules[\/\\]react[\/\\]dist[\/\\].*/,
  /website\/node_modules\/.*/,
  /heapCapture\/bundle\.js/,
  /.*\/__tests__\/.*/
];

Hope it works like worked for me :)

finally i could did this thanks to you!

@RealDyllon
Copy link

RealDyllon commented Nov 24, 2019

@lucasgit2000 's solution worked for me. Thanks mate.

Edit: running nodejs v12.13.1 (I didn’t downgrade)

@sugeng-sulistiyawan
Copy link

Tried
12.11 👎
12.10 👎
12.9 👍 ✔

Using expo-cli 3.3.0.

Worked for me!!

@rahul12330
Copy link

i just start react native using expo cli .. and get this error and im confused..
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 details.

Metro Bundler process exited with code 1
Set EXPO_DEBUG=true in your env to view the stack trace.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ start: expo start
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\user\AppData\Roaming\npm-cache_logs\2019-10-12T13_00_57_090Z-debug.log

How did you solve this?

@RealDyllon
Copy link

@rahul12330 instructions here: #1074 (comment)

@mridul037
Copy link

https://stackoverflow.com/questions/58120990/how-to-resolve-the-error-on-react-native-start/58199866#58199866

see this stack overflow discussion
you just have to change \node_modules\metro-config\src\defaults\blacklist.js .

var sharedBlacklist = [
  /node_modules[/\\]react[/\\]dist[/\\].*/,
  /website\/node_modules\/.*/,
  /heapCapture\/bundle\.js/,
  /.*\/__tests__\/.*/
];

this to

var sharedBlacklist = [
  /node_modules[\/\\]react[\/\\]dist[\/\\].*/,
  /website\/node_modules\/.*/,
  /heapCapture\/bundle\.js/,
  /.*\/__tests__\/.*/
];

Note:: each time you do npm install do update the file

@tim92109
Copy link

Real bummer about Expo which is the only reason I sometimes don't like developing in React. Last 5 expo updates caused issues including this one. HATE it when I see a new version of Expo is available. Wish they would at least test new versions before pushing them.

@KHARCHO
Copy link

KHARCHO commented Nov 26, 2019

Must downgrade to 12.9.1 version of Node.js ... I think that is the latest version that works without crashing... here is the download link:

https://nodejs.org/download/release/v12.9.1/

@tarunjuneja
Copy link

tarunjuneja commented Nov 27, 2019

after node downgrade i further did

npm uninstall --g expo-cli
npm install --g expo-cli

to be able to compile my code

I did not make change into any local node module. Everything worked.

@prititripathi
Copy link

@hadessama1994 thank you so much :)
Saved my day.

@deadmann
Copy link

Real bummer about Expo which is the only reason I sometimes don't like developing in React. Last 5 expo updates caused issues including this one. HATE it when I see a new version of Expo is available. Wish they would at least test new versions before pushing them.

that why from my child hood i believed in Microsoft, you hardly found a functionally that get remove and cause old code to crash, you still can run and use codes from hundred of years ago :-"
Yet since new manager open the door to Open Source developer,... i'm losing my believes in them too... but codes should be solid, we should add, not remove, we may only flag obsolete functionality, but not change or remove them,... just add to system in a way that doesn't target the old codes.

@RealDyllon
Copy link

Real bummer about Expo which is the only reason I sometimes don't like developing in React. Last 5 expo updates caused issues including this one. HATE it when I see a new version of Expo is available. Wish they would at least test new versions before pushing them.

that why from my child hood i believed in Microsoft, you hardly found a functionally that get remove and cause old code to crash, you still can run and use codes from hundred of years ago :-"
Yet since new manager open the door to Open Source developer,... i'm losing my believes in them too... but codes should be solid, we should add, not remove, we may only flag obsolete functionality, but not change or remove them,... just add to system in a way that doesn't target the old codes.

Have you even used Windows 10?

@soletan
Copy link

soletan commented Nov 27, 2019

@fson It's a pity no one's picking up your real solution here but adding more noise to the comments. Any chance to get your fix without requiring someone updating this repo's dependencies first?

@brentvatne
Copy link
Member

brentvatne commented Nov 27, 2019

👋 if you came here from the expo-cli warning.

the recommended solution is to do the following:

  • delete node_modules
  • delete your lockfiles (npm-lock.json or yarn.lock)
  • run npm install or yarn again.

the important thing is that when you install your dependencies you end up with metro@0.56.4 or greater in your lockfile!


does this now work for you for some reason? other temporary solutions if you encounter this error are:

option 1. downgrade to node 12.9
option 2. follow these instructions to patch node_modules: https://stackoverflow.com/a/58199866/659988

if you are curious why you are seeing this error, it is because a specific version of a package called metro-config (a package used by react-native) has some code that is incompatible with certain versions of node 12.

@expo expo locked as off-topic and limited conversation to collaborators Nov 27, 2019
@brentvatne brentvatne self-assigned this Nov 27, 2019
carlosloureda referenced this issue in udacity/reactnd-UdaciFitness-complete Feb 1, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests