简体   繁体   English

SyntaxError:意外的令牌反应本机初始化

[英]SyntaxError: Unexpected token react-native init

Hello I am getting an issue when trying to run react-native init . 您好,我在尝试运行react-native init时遇到问题。

SyntaxError: Unexpected token ...

/Users/jordan/Projects/React/LiveInstagram/node_modules/metro-bundler/build/lib/TerminalClass.js:141 this._nextStatusStr = util.format(format, ...args);

Does anyone know how I can remedy this issue? 有谁知道我该如何解决? Thanks! 谢谢!

There are compatibility issues in the updated react-native cli. 更新后的本机cli中存在兼容性问题。 Using the downgraded version solves this problem. 使用降级版本可以解决此问题。 $ react-native init [project name] --version 0.38.0 $ react-native init [项目名称]-版本0.38.0

https://github.com/facebook/react-native/issues/11384 https://github.com/facebook/react-native/issues/11384

Currently it works for me with node v8. 目前,它适用于节点v8。 My solution: 我的解决方案:

sudo npm install -g npm
sudo npm cache clean -f
sudo npm install -g n
sudo n stable

因此,我完全卸载了Node然后重新安装了它并进行了react-native-cli ,使其正常工作。

I had the same problem with nodejs v4, solve this by updating nodejs and npm. 我在使用nodejs v4时遇到了同样的问题,请通过更新nodejs和npm解决此问题。 sudo purge nodejs npm curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash - sudo apt-get install -y nodejs

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM