React项目执行npm install时安装styled-components出现null属性读取错误
解决npm安装styled-components时出现"cannot read the properties of null (read 'edgesOut')"错误
清理npm缓存
执行命令:npm cache clean --force,强制清除本地缓存,避免缓存损坏引发的安装异常。删除旧依赖文件
手动删掉项目根目录下的node_modules文件夹,同时删除package-lock.json文件(用yarn的话删yarn.lock),清除可能存在的损坏依赖或版本冲突文件。重新安装依赖
直接执行npm install安装全部依赖,或者单独安装styled-components:npm install styled-components。如果还是报错,试试加--force参数强制安装:npm install styled-components --force。升级npm版本
先看当前npm版本:npm -v,如果版本偏旧,执行npm install -g npm@latest升级到最新版,旧版本npm可能存在依赖解析的bug,升级后大概率能解决问题。切换npm源(可选)
要是网络原因导致依赖包下载不完整,切换到国内镜像源,比如:npm config set registry https://registry.npmmirror.com/,之后再重新执行安装命令。
内容的提问来源于stack exchange,提问作者Mohammad Hasan Abbas
相关产品推荐
相关产品推荐

