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

Ruby on Rails中如何移除通过Yarn添加的依赖包?

移除Yarn添加的依赖及相关文件

步骤1:移除指定的Yarn依赖包

在项目根目录下执行以下命令,会自动从package.json的dependencies中移除jquery和bootstrap,同时更新yarn.lock文件:

yarn remove jquery bootstrap

步骤2:清理生成的文件(按需执行)

如果需要彻底清除本次Yarn操作生成的所有文件:

  • 删除node_modules目录:
    Linux/macOS:
    rm -rf node_modules
    
    Windows命令行:
    rmdir /s node_modules
    
    Windows PowerShell:
    Remove-Item -Recurse -Force node_modules
    
  • 删除package.json文件:
    Linux/macOS:
    rm package.json
    
    Windows:
    del package.json
    
  • 删除yarn.lock文件:
    Linux/macOS:
    rm yarn.lock
    
    Windows:
    del yarn.lock
    

补充:清理Ruby Gem中的Bootstrap(若不需要)

你的Gemfile中还配置了Ruby版本的Bootstrap,若不再需要,可手动编辑Gemfile删除以下行:

gem "bootstrap", "~> 5.2.0"

然后执行命令更新依赖:

bundle install

内容的提问来源于stack exchange,提问作者JS3

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.28 21:53:06