请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

react-native 不支持 node v4.2.3 了!!!

react-native init imoocApp
This will walk you through creating a new React Native project in /Users/lafa/Projects/imoocApp
Installing react-native package from npm…

You are currently running Node v4.2.3 but React Native requires >=8. Please use a supported version of Node. See https://facebook.github.io/react-native/docs/getting-started.html

/Users/lafa/Projects/imoocApp/node_modules/react-native/local-cli/server/checkNodeVersion.js:43
);
^

SyntaxError: Unexpected token )
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:414:25)
at Object.Module._extensions…js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object. (/Users/lafa/Projects/imoocApp/node_modules/react-native/local-cli/cli.js:17:1)
at Module._compile (module.js:435:26)
at Object.Module._extensions…js (module.js:442:10)

正在回答 回答被采纳积分+3

1回答

Scott 2018-09-13 08:55:30

恩,可以把 Nodejs 升级下版本,比如升到 8.x

0 回复 有任何疑惑可以回复我~
  • 提问者 qml123 #1
    node 升级的8.3 以上。今天 测试了一天,最终把node 升级到v8.12.0,react-native-cli 升级到2.0.1,根据中文官方文档换做yarn(v1.9.4),才顺利跑起来了“react-native  init  imoocApp”命令。之前用npm命令执行到一半卡住不动了,可能翻不了墙网速有关。
    回复 有任何疑惑可以回复我~ 2018-09-13 16:12:20
  • 提问者 qml123 #2
    不过执行启动命令有报新的错误了,react-native@0.57.0" 版本是最新的了:
    react-native run-ios
    Found Xcode project imoocApp.xcodeproj
    xcrun: error: unable to find utility "instruments", not a developer tool or in PATH
    
    Command failed: xcrun instruments -s
    xcrun: error: unable to find utility "instruments", not a developer tool or in PATH
    
    
    Error: Command failed: xcrun instruments -s
    xcrun: error: unable to find utility "instruments", not a developer tool or in PATH
    
        at checkExecSyncError (child_process.js:602:13)
        at Object.execFileSync (child_process.js:622:13)
        at Object.runIOS [as func] (/Users/lafa/AppDir/imoocApp/node_modules/react-native/local-cli/runIOS/runIOS.js:76:17)
        at Promise.resolve.then (/Users/lafa/AppDir/imoocApp/node_modules/react-native/local-cli/cliEntry.js:117:22)
        at <anonymous>
    
    感觉还是有好多坑啊
    回复 有任何疑惑可以回复我~ 2018-09-13 16:14:30
  • 提问者 qml123 #3
    后来直接在Xcode中打开项目文件进去了。按报错提示需要先添加开发者账号,然后才开始编译项目,最后成功跑起来了。
    回复 有任何疑惑可以回复我~ 2018-09-13 16:33:14
问题已解决,确定采纳
还有疑问,暂不采纳
意见反馈 帮助中心 APP下载
官方微信