所以我一直在关注本教程: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感到非常沮丧,因为刚开始安装时就做出了响应是一个麻烦,而且现在我什至无法测试一个非常简单的应用程序。 感谢您的帮助,在此先感谢!