react-native - `react-native init AwesomeProject` 抛出语法错误

标签 react-native react-native-cli

react-native init AwesomeProject 抛出 SyntaxError: Unexpected token : 我不知道为什么。我已经卸载并重新安装了react-native-cli。尝试过使用和不使用 yarn 。有什么建议吗?

mes-MBP:myproject me$ react-native init AwesomeProject
This will walk you through creating a new React Native project in /Users/me/WebstormProjects/myproject/AwesomeProject
Using yarn v0.17.10
Installing react-native...
/Users/me/WebstormProjects/myproject/AwesomeProject/node_modules/react-native/local-cli/util/Config.js:43
  cwd: string,
     ^

SyntaxError: Unexpected token :
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:387:25)
    at loader (/Users/me/WebstormProjects/myproject/AwesomeProject/node_modules/babel-register/lib/node.js:144:5)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/me/WebstormProjects/myproject/AwesomeProject/node_modules/babel-register/lib/node.js:154:7)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/me/WebstormProjects/myproject/AwesomeProject/node_modules/react-native/local-cli/cliEntry.js:13:16)
    at Module._compile (module.js:413:34)

最佳答案

看起来更新发布到 react-native 时出现错误。其他人也遇到了同样的问题,所以我将回答这个问题并说这是一个软件包问题。 https://github.com/facebook/react-native/issues/11384


在这个问题得到解决之前,您可以使用rninit ( https://www.npmjs.com/package/rninit ) 使用 react-native 的先前版本进行安装。这对我有用:
rninit init mobile --source <a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0270676361762f6c63766b746742322c313b2c32" rel="noreferrer noopener nofollow">[email protected]</a>

关于react-native - `react-native init AwesomeProject` 抛出语法错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41051572/

相关文章:

react-native - 在 React Native Android 的项目 ':react-native-google-sign-in' 中找不到路径为 ':app' 的项目

reactjs - react native 开始给出无效的正则表达式无效错误

react-native - 如何使用特定目标运行react-native run-ios

android - 未满足的对等依赖 React Native CLI Init

android - 在android应用程序中 react native 力光模式

javascript - this.props.navigation.navigate() 不起作用

react-native-video 在我的应用程序中显示空白屏幕,没有任何错误日志

react-native - 在 bazel 构建中运行 react-native cli

reactjs - React Native - 找不到模块 X 或其相应的类型声明

javascript - 适用于 Android 的 React Native 日期和时间选择器不起作用