ReactNative环境配置问题

本文针对ReactNative开发过程中出现的两个典型错误进行了解析:无法读取'root'属性的空值错误及无法解析ReactDefaultPerf模块的问题,并提供了详细的解决步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题1 - Cannot read property ‘root’ of null

  • 详细报错信息:
<START> fs crawl
TypeError: Cannot read property 'root' of null
    at /Users/wusuowei/Documents/WorkSpace/20160525/Demo/node_modules/react-native/packager/react-packager/src/DependencyResolver/crawlers/index.js:16:84
    at tryCallOne (/Users/wusuowei/Documents/WorkSpace/20160525/Demo/node_modules/react-native/node_modules/promise/lib/core.js:37:12)
    at /Users/wusuowei/Documents/WorkSpace/20160525/Demo/node_modules/react-native/node_modules/promise/lib/core.js:103:15
    at flush (/Users/wusuowei/Documents/WorkSpace/20160525/Demo/node_modules/react-native/node_modules/promise/node_modules/asap/raw.js:50:29)
    at doNTCallback0 (node.js:408:9)
    at process._tickCallback (node.js:337:13)
  • 原因

    watchman版本需要更新

  • 解决

$ brew update
$ brew uninstall watchman
$ brew unlink watchman
$ brew install watchman --HEAD
  • 注意

    假如你的Homebrew安装的比较早,就有可能更新时会遇到相关的权限问题,你可以参考Homebrew简介和基本使用解决.

问题2 - Unable to resolve module ReactDefaultPerf from

  • 详细报错信息:

Unable to resolve module ReactDefaultPerf from /Users/wusuowei/Documents/WorkSpace/20160525/Demo/node_modules/react-native/Libraries/react-native/react-native.js: Unable to find this module in its module map or any of the node_modules directories under /Users/node_modules/ReactDefaultPerf and its parent directories
```

  • 原因

    react版本和react-native版本不匹配。1

  • 解决

     $ npm install <react@version>
    

    示例:

     $ npm install react@15.0.2
    
  • 注意

在完整的报错信息中会有提示你移除当前所有的node modules和watchman的相关操作,我尝试后发现并没有解决问题,同时也有官方issue的提示,遇到类似问题,你可以先看看这个问题的解决和回复,然后在决定如何解决。(ps,重新下载所有的node依赖太慢了)

参考

相关

注解

  • react 15.1.0 match react-native 0.27.0-rc
  • react 15.0.2 match react-native 0.26.x

  1. 官方issues中的回复中可以注意到: ↩︎

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值