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 Start error after uninstall/install of expo-cli and nodejs #1147

Closed
markclynch opened this issue Oct 22, 2019 · 4 comments
Closed

Expo Start error after uninstall/install of expo-cli and nodejs #1147

markclynch opened this issue Oct 22, 2019 · 4 comments

Comments

@markclynch
Copy link

Description

Failing to publish, used bug fix of reinstalling, 1. deleting node modules, deleting node.js uninstalling expo-cli, 2. reinstalling latest version LTS node.js, reinstalling expo-cli, npm install in root, npm run start - showed following.

Expected Behavior

Initial problem with publishing to Expo. specific node_module error with which version created with and which version used for publishing. Uninstalled node and expo and reinstalled now new error, will not run Expo Start

Observed Behavior

npm run start

@ start C:\Users\Mark\projects\wack-a-mole-clone
expo start

Starting project at C:\Users\Mark\projects\wack-a-mole-clone
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.
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\Mark\AppData\Roaming\npm-cache_logs\2019-10-22T02_20_23_284Z-debug.log

If there's an error message, please paste the full terminal output and error message in this code block:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'start'
1 verbose cli ]
2 info using npm@6.12.0
3 info using node@v12.13.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle @~prestart: @
6 info lifecycle @~start: @
7 verbose lifecycle @~start: unsafe-perm in lifecycle true
8 verbose lifecycle @~start: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\Mark\projects\wack-a-mole-clone\node_modules\.bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\Mark\bin;C:\ProgramData\DockerDesktop\version-bin;C:\Program Files\Docker\Docker\Resources\bin;C:\Python27;C:\Python27\Scripts;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0;C:\WINDOWS\System32\OpenSSH;C:\Program Files\Git\cmd;C:\ProgramData\chocolatey\bin;C:\Program Files\dotnet;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn;C:\Program Files\nodejs;C:\Users\Mark\AppData\Local\Microsoft\WindowsApps;C:\Users\Mark\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Mark\AppData\Roaming\npm
9 verbose lifecycle @~start: CWD: C:\Users\Mark\projects\wack-a-mole-clone
10 silly lifecycle @~start: Args: [ '/d /s /c', 'expo start' ]
11 silly lifecycle @~start: Returned: code: 1  signal: null
12 info lifecycle @~start: Failed to exec start script
13 verbose stack Error: @ start: `expo start`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:210:5)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:210:5)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
14 verbose pkgid @
15 verbose cwd C:\Users\Mark\projects\wack-a-mole-clone
16 verbose Windows_NT 10.0.18362
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "start"
18 verbose node v12.13.0
19 verbose npm  v6.12.0
20 error code ELIFECYCLE
21 error errno 1
22 error @ start: `expo start`
22 error Exit status 1
23 error Failed at the @ start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Environment

Expo CLI 3.4.1 environment info:
System:
OS: Windows 10
Binaries:
npm: 6.12.0 - C:\Program Files\nodejs\npm.CMD
IDEs:
Android Studio: Version 3.5.0.0 AI-191.8026.42.35.5900203

Also specify:

Not important.

  • Phone/emulator/simulator platform, model and version:

Reproducible Demo

Please provide a minimized reproducible demonstration of the problem you're reporting.

Issues that come with minimal repro's are resolved much more quickly than issues where a maintainer has to reproduce themselves.

@WasimHamid
Copy link

I am getting the same problem.

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

@markclynch
Copy link
Author

Wasim, I found a correction that solves the problem for testing. Alternatively you can downgrade to 12.10 Node.js. if you google first line or so of the regex from error you should find the correction in Stack Overflow article.

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
@fson
Copy link
Contributor

fson commented Nov 14, 2019

Closing this issue as a duplicate of #1074.

@fson fson closed this as completed Nov 14, 2019
cpojer pushed a commit to facebook/metro that referenced this issue Jan 8, 2020
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
@quangdutran
Copy link

I face this problem too. Install lates node 12.16.1 does not work, 12.10 and 12.13 do not work either.

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

4 participants