I just installed node.js & cli
installed react-native-cli
npm -g react-native-cli
This is caused by node v12.11.0 due to the way it deals regular location there two ways to solve this problem
Method I
You can downgrade to node v12.10.0 this will apply the correct way to deal with parsing error
Method II
You can correctly terminate the regular expression in you case by changing the file located a:
\node_modules\metro-config\src\defaults\blacklist.js
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__\/.*/
];
A PR with a fix has been merged in the metro repository. Now we just need to wait until the next release. For now the best option is to downgrade to NodeJS v12.10.0
. As Brandon pointed out, modifying anything in node_modules/
isa really bad practice and will not be a final solution.
https://github.com/facebook/metro/issues/453
for who still get this error without official patch in react-native , expo
use yarn and add this setting into package.json
{
...
"resolutions": {
"metro-config": "bluelovers/metro-config-hotfix-0.56.x"
},
...
All mentioned comments above are great, sharing the path that worked with me for this Blacklist file that need to be edited:
"Your project name\node_modules\metro-bundler\src" File name "blacklist.js"
As a general rule, I don't modify files within node_modules/
(or anything which does not get committed as part of a repository) as the next clean, build or update will regress them. I definitely have done so in the past and it has bitten me a couple of times. But this does work as a short-term/local dev fix until/unless metro-config
is updated.
Thanks!
Go to
\node_modules\metro-config\src\defaults\blacklist.js
and replace this
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 is not a best practice and my recommendation is: downgrade node version into 12.9 OR update metro-config since they are fixing the Node issue.