react native 更新后packager启动失败:SyntaxError: Unexpected token ...

本文记录了一次React Native版本更新后遇到的包管理器无法启动的问题及解决方案。错误提示为SyntaxError: Unexpected token,原因在于React Native 0.46版本开始采用ES6语法,而旧版Node.js不支持新特性。文章提供了升级Node.js版本的具体步骤。

更新了下react native版本,突然发现packager就无法启动了。报错SyntaxError: Unexpected token ... 具体如下:

######### Starting Packager ##########

######### Executing command: react-native start --port 8081 ##########
/Users/liduola-android/duola-for-js/node_modules/metro-bundler/src/lib/Terminal.js:141
this._nextStatusStr = util.format(format, ...args);
^^^

SyntaxError: Unexpected token ...
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Module._extensions..js (module.js:416:10)
at Object.require.extensions.(anonymous function) [as .js] (/Users/liduola-android/duola-for-js/node_modules/metro-bundler/node_modules/babel-register/lib/node.js:152:7)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/Users/liduola-android/duola-for-js/node_modules/react-native/local-cli/server/runServer.js:18:18)
at Module._compile (module.js:409:26)
[Error : 0106] Failed to start the React Native packager: Could not start the packager.

在这里找到了解决办法:github  原因是react native 0.46之后使用ES6语法,如果node版本太低,就无法识别...这种延伸操作符,所以需要更新到node v6以上。

node 更新的方法在这里:点击打开链接 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值