我刚刚安装了 node.js & cli
- 安装 node.js
- 安装了 react-native-cli
npm -g react-native-cli
并创建了一个“新项目”。
react-native init new_project
- 在那个’new_project’目录中,我很想看看metro bundler是否运作良好。
react-native start
但是该命令给了我以下错误,并且地铁没有启动。修复此错误的任何线索? (我使用的是 Windows 10 操作系统。)
- 命令:
C:\projects\new_proj>react-native start
错误正则表达式无效:/(.\fixtures.|node_modules[]react[]dist[].|website\node_modules.|heapCapture\bundle.js|.\tests.)\(/: 未终止的字符类。使用 --verbose 标志运行 CLI 以获取更多详细信息。 SyntaxError: 无效的正则表达式:/(.\\fixtures.\|node_modules\[\]react\[\]dist\[\].\|website\\node_modules.\|heapCapture\\bundle.js\|.\\tests.)\)/: 在新的 RegExp ( ) 在黑名单 (D:\projects\new_proj\node_modules\metro-config\src\defaults\blacklist.js:34:10) 在 getBlacklistRE (D:\projects\new_proj\node_modules\react-native\node_modules@react-native -community\cli\build\tools\loadMetroConfig.js:69:59) 在 getDefaultConfig (D:\projects\new_proj\node_modules\react-native\node_modules@react-native-community\cli\build\tools\loadMetroConfig.js :85:20) 在加载 (D:\projects\new_proj\node_modules\react-native\node_modules@react-native-community\cli\build\tools\loadMetroConfig.js:121:25) 在 Object.runServer [as func ] (D:\projects\new_proj\node_modules\react-native\node_modules@react-native-community\cli\build\commands\server\runServer.js:82:58) 在 Command.handleAction (D:\projects\new_proj \node_modules\react-native\node_modules@react-native-community\cli\build\cliEntry.js:160: 21) 在 Command.listener (D:\projects\new_proj\node_modules\commander\index.js:315:8) 在 Command.emit (events.js:210:5) 在 Command.parseArgs (D:\projects\new_proj \node_modules\commander\index.js:651:12)
- 命令:
原文由 Song Kevin 发布,翻译遵循 CC BY-SA 4.0 许可协议
我今天第一次遇到类似的错误。它出现在
\node_modules\metro-config\src\defaults\blacklist.js
中,存在需要更改的无效正则表达式。我更改了sharedBlacklist
下的第一个表达式:到: