reactjs - 全新安装后尝试运行本机应用程序时出错
问题描述
所以我一直在关注本教程:youtube.com/watch?v=qSRrxpdMpVc 尝试学习应用程序开发的本机反应,但我一直受到问题的困扰。使用 expo 创建项目后,使用 expo-template-blank 运行:
expo init first
然后创建这个非常简单的应用程序,就像我在教程中学到的那样:
import React, {useState} from 'react';
import { StyleSheet, Text, View, Button } from 'react-native';
export default function App() {
const[outputText, setOutputText] = useState('New State');
return (
<View style={styles.container}>
<Text>{outputText}</Text>
<Button title="Change Text" onPress={() => setOutputText('the text changed')}/>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
我试图通过 cd 到目录测试应用程序,然后运行
yarn start
但是当我这样做时,我得到了这个巨大的错误:
C:\www\first>yarn start
yarn run v1.21.0
warning ..\package.json: No license field
$ expo start
Starting project at C:\www\first
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.
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:\www\first\node_modules\metro-config\src\defaults\blacklist.js:34:10)
at getBlacklistRE (C:\www\first\node_modules\@react-native-community\cli\build\tools\loadMetroConfig.js:66:59)
at getDefaultConfig (C:\www\first\node_modules\@react-native-community\cli\build\tools\loadMetroConfig.js:82:20)
at load (C:\www\first\node_modules\@react-native-community\cli\build\tools\loadMetroConfig.js:118:25)
at Object.runServer [as func] (C:\www\first\node_modules\@react-native-community\cli\build\commands\server\runServer.js:82:58)
at Command.handleAction (C:\www\first\node_modules\@react-native-community\cli\build\index.js:164:23)
at Command.listener (C:\www\first\node_modules\commander\index.js:315:8)
at Command.emit (events.js:210:5)
at Command.parseArgs (C:\www\first\node_modules\commander\index.js:651:12)
Metro Bundler process exited with code 1
Set EXPO_DEBUG=true in your env to view the stack trace.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
有谁知道这可能是什么原因造成的?我对 React 感到非常沮丧,因为刚开始安装 React 是一件很麻烦的错误,现在我什至无法测试一个非常简单的应用程序。感谢您的帮助,在此先感谢!
解决方案
推荐阅读
- java - 图生成器侦听器中的 JMeter java.io.FileNotFoundException
- python - 根据条件python将dict值从一个更新到另一个
- google-chrome - 使用 Chrome 远程调试 Android 设备重定向 URL
- c# - 生产者消费者模型中队列为空时消费者的最佳行为是什么
- windows - Powershell 删除文件名中的 Em Dash 无法识别 Em Dash
- c++ - 支持两个具有不同语义的整数构造函数
- visual-studio - Visual Studio Post-Build 事件 - 如果文件位于子文件夹中,如何将文件复制到输出(bin)目录(仅当较新时)
- c++ - Incredibuild,编译期间的内部 LD_PRELOAD 错误
- python - 有条件地计算列的最大值和最小值
- azure-devops - 如何在已发布的工件中包含测试程序集?