Monday, October 21, 2019

error Invalid regular expression

Example : #1

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.
SyntaxError: Invalid regular expression: /(.*\\__fixtures__\\.*|node_modules[\\\]react[\\\]dist[\\\].*|website\\node_modules\\.*|heapCapture\\bundle\.js|.*\\__tests__\\.*)$/: Unterminated character class
    at new RegExp (<anonymous>)
    at blacklist (C:\Users\sapan\Desktop\React Native\demo\node_modules\metro-config\src\defaults\blacklist.js:41:10)
    at getBlacklistRE (C:\Users\sapan\Desktop\React Native\demo\node_modules\@react-native-community\cli\build\tools\loadMetroConfig.js:66:59)
    at getDefaultConfig (C:\Users\sapan\Desktop\React Native\demo\node_modules\@react-native-community\cli\build\tools\loadMetroConfig.js:82:20)
    at load (C:\Users\sapan\Desktop\React Native\demo\node_modules\@react-native-community\cli\build\tools\loadMetroConfig.js:118:25)
    at Object.runServer [as func] (C:\Users\sapan\Desktop\React Native\demo\node_modules\@react-native-community\cli\build\commands\server\runServer.js:82:58)
    at Command.handleAction (C:\Users\sapan\Desktop\React Native\demo\node_modules\@react-native-community\cli\build\index.js:164:23)
    at Command.listener (C:\Users\sapan\Desktop\React Native\demo\node_modules\commander\index.js:315:8)
    at Command.emit (events.js:210:5)

    at Command.parseArgs (C:\Users\sapan\Desktop\React Native\demo\node_modules\commander\index.js:651:12)


................................................................................................................................

Solutions -


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



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


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

];
keep learning :)
............................................................................................................................

Example : #2
error React Native CLI uses autolinking for native dependencies, but the following modules are linked manually: - react-native-firebase (to unlink run: "react-native unlink react-native-firebase"

solutions -

Create a react-native.config.js file in the root of your project.

Update it to something like this:
// react-native.config.js
module.exports = {
  dependencies: {
    '<dependency>': {
      platforms: {
        android: null, // disable Android platform, other platforms will still autolink
      },
    },
  },
};


in my case is look like below

module.exports = {
    dependencies: {
    'react-native-firebase': {
    platforms: {
    android: null,
    },
    },
    },
    };
    

keep learning :)
....................................................................................................

2 comments: