node.js - React-native npm start启动报错!
伊谢尔伦
伊谢尔伦 2017-04-17 13:01:45
[Node.js讨论组]

我是跟着RN官网的教程来玩的:
https://facebook.github.io/react-native/docs/getting-started.html#content
求解惑

启动时在终端看到的错误信息如下

/Users/yiwang/Documents/react_native/AwesomeProject/node_modules/react-native/local-cli/cli.js:56
const setupEnvScript = /^win/.test(process.platform)
^^^^^
SyntaxError: Use of const in strict mode.

at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Module._extensions..js (module.js:478:10)
at Object.require.extensions.(anonymous function) [as .js] (/Users/yiwang/Documents/react_native/AwesomeProject/node_modules/react-native/node_modules/babel-core/lib/api/register/node.js:214:7)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Users/yiwang/Documents/react_native/AwesomeProject/node_modules/react-native/cli.js:15:18)
伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

全部回复(2)
巴扎黑

升级node到4.1以上。

巴扎黑

需要升级node,但是如果你使用的是nvm来管理node的版本的话。
直接使用node use <不同版本>,如果你系统版本是低于react-native要求的版本的话,也会有问题。
因为react-native在启动时会开启一个新窗口,如果你没有在.xxx之类的配置文件配置的话,还是会有问题。

1.建议使用nvm来管理node(很有可能处于某种原因不想放弃之前旧版本的node的项目);
2.使用nvm alias default stable(这里使用最新版作为默认版本,需要使用nvm install stable安装最新版本)

祝君好运!

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号