@emotion/styled-base弃用后Rails应用启动报错求助
解决@emotion/styled-base弃用后仍被加载的问题
当前使用的依赖包
"react": "^18.2.0", "@emotion/react": "^11.1.3", "@emotion/styled": "^11.0.0", "@emotion/styled-base": "^11.0.0", "webpack": "^5.79.0", "webpack-cli": "^5.0.1",
问题描述
@emotion/styled-base已被官方弃用,删除该包后系统仍尝试加载它。执行yarn build无任何错误或警告,但启动Rails应用时出现错误,组件无法加载:
@emotion/styled包中的新入口@emotion/styled/base已替代@emotion/styled-base包,请移除该包并改用@emotion/styled/base。
解决方案
彻底移除弃用包
执行命令卸载@emotion/styled-base:yarn remove @emotion/styled-base # 或使用npm npm uninstall @emotion/styled-base替换代码中的导入路径
全局搜索项目中所有@emotion/styled-base的导入语句,替换为@emotion/styled/base:// 替换前 import styled from '@emotion/styled-base' // 替换后 import styled from '@emotion/styled/base'清理依赖缓存并重装
清除依赖缓存,避免残留的旧包引用:# yarn用户 yarn cache clean && yarn install # npm用户 npm cache clean --force && npm install重新构建项目
执行构建命令确保新依赖生效:yarn build检查webpack配置(若有自定义配置)
查看webpack配置文件中是否存在指向@emotion/styled-base的别名配置,如有则更新为@emotion/styled/base。
内容的提问来源于stack exchange,提问作者omr
相关产品推荐
相关产品推荐

