安装styled-components时出现React报错:Cannot read properties of null (reading 'edgesOut')
解决npm安装styled-components时报"Cannot read properties of null (reading 'edgesOut')"的方案
报错信息
npm ERR! Cannot read properties of null (reading 'edgesOut') npm ERR! A complete log of this run can be found in: C:\Users\igor\AppData\Local\npm-cache\_logs\2023-05-08T23_16_20_252Z-debug-0.log
可行解决步骤
彻底清理npm缓存后重试:
npm cache clean --force清理完成后重新执行
npm install styled-components指定具体版本安装(避开可能存在兼容问题的版本):
例如安装稳定的5.x版本:npm install styled-components@5.3.11或尝试最新稳定版:
npm install styled-components@latest切换npm源后重试:
切换到官方源:npm config set registry https://registry.npmjs.org/或国内镜像源:
npm config set registry https://registry.npmmirror.com/切换完成后重新执行安装命令
升级Node.js和npm版本:
确保Node.js为LTS版本(如18.x或20.x),npm版本对应适配,升级后再尝试安装换用yarn包管理器安装:
先全局安装yarn:npm install -g yarn再执行安装:
yarn add styled-components
内容的提问来源于stack exchange,提问作者Igor Macedo
相关产品推荐
相关产品推荐

