`react-native init AwesomeProject` 抛出 SyntaxError [英] `react-native init AwesomeProject` throwing SyntaxError

查看:49
本文介绍了`react-native init AwesomeProject` 抛出 SyntaxError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

react-native init AwesomeProject is throwing SyntaxError: Unexpected token : and I'm not sure why. I've uninstalled and re-installed react-native-cli. Tried with and without yarn. Any suggestions?

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

Looks like the error an update was published to react-native. Others are experiencing the same issue so I'm going to answer this and say it's a package issue. https://github.com/facebook/react-native/issues/11384

在此问题得到解决之前,您可以使用 rninit(https://www.npmjs.com/package/rninit) 使用以前版本的 react-native 安装.这对我有用:
rninit init mobile --source react-native@0.39.0

Until this gets resolved, you can use rninit(https://www.npmjs.com/package/rninit) to install using the previous version of react-native. This worked for me:
rninit init mobile --source react-native@0.39.0

这篇关于`react-native init AwesomeProject` 抛出 SyntaxError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆