You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

@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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.18 23:59:54