How to resolve the error on 'react-native start'

后端 未结 19 2526
说谎
说谎 2020-11-29 15:41
  1. I just installed node.js & cli

    • installed node.js
    • installed react-native-cli

      npm -g react-native-cli
      
相关标签:
19条回答
  • 2020-11-29 16:09

    On windows 10 i highly recommend to install Linux Bash Shell.

    Here is a nice guide to set it up: https://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/

    just follow the steps, choose your linux distribution and avoid as much possible to work with node on cmd since obvious instability.

    Take in consideration Microsoft strongly warns against adding or modifying Linux files with Windows software, as described here: howtogeek.com/261383/how-to-access-your-ubuntu-bash-files-in-windows-and-your-windows-system-drive-in-bash/

    Hope it helps!

    0 讨论(0)
  • 2020-11-29 16:09

    I have just update package.json to change from

    "react-native": "https://github.com/expo/react-native/archive/sdk-35.0.0.tar.gz"
    

    to

    "react-native": "https://github.com/expo/react-native/archive/sdk-36.0.0.tar.gz"
    

    It seems that the problem won't occur in sdk-36 !!

    My node version is v12.16.0 and os is win10.

    0 讨论(0)
  • 2020-11-29 16:12

    You can go to...

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

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

    for this:

    var sharedBlacklist = [
      /node_modules[\/\\]react[\/\\]dist[\/\\].*/,
      /website\/node_modules\/.*/,
      /heapCapture\/bundle\.js/,
      /.*\/__tests__\/.*/
    ];
    
    0 讨论(0)
  • 2020-11-29 16:13

    I just got a similar error for the first time today. It appears in \node_modules\metro-config\src\defaults\blacklist.js, there is an invalid regular expression that needed changed. I changed the first expression under sharedBlacklist 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__\/.*/
    ];
    
    0 讨论(0)
  • 2020-11-29 16:19

    I don't have metro-config in my project, now what?

    I have found that in pretty older project there is no metro-config in node_modules. If it is the case with you, then,

    Go to node_modules/metro-bundler/src/blacklist.js

    And do the same step as mentioned in other answers, i.e.

    Replace

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

    with

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

    P.S. I faced the same situation in a couple of projects so thought sharing it might help someone.

    Edit

    As per comment by @beltrone the file might also exist in,

    node_modules\metro\src\blacklist.js

    0 讨论(0)
  • 2020-11-29 16:19

    Fix it by install metro-config of the latest version (0.57.0 for now) they had fixed the problem:

    npm install metro-config

    you can remove it later, after react-native guys update module versions

    0 讨论(0)
提交回复
热议问题