Cursor plugin:把当前仓库的 node_modules 软链到另一处已安装依赖的目录,跳过 npm install / yarn。
- 复用本机另一仓库的
node_modules,省时间、省磁盘 - 记住上次源路径(写在目标仓库
.cursor/link-node-modules/.last-source) - 真实目录默认不覆盖;需用户明确同意才可用
--force
mkdir -p ~/.cursor/plugins/local
ln -sfn /path/to/cursor-plugin-link-node-modules \
~/.cursor/plugins/local/link-node-modules然后在 Cursor 执行 Developer: Reload Window,在 Customize 中确认 skill link-node-modules 已加载。
对话里可以说:「用软链安装包」,并给出已装依赖的源仓库路径。
node skills/link-node-modules/scripts/link-node-modules.js \
--source /path/to/repo-with-node_modules
# 省略 --source 时复用目标仓库记忆
node skills/link-node-modules/scripts/link-node-modules.js
# 指定目标仓库
node skills/link-node-modules/scripts/link-node-modules.js \
--source /path/to/source-repo \
--target /path/to/target-repocursor-plugin-link-node-modules/
├── .cursor-plugin/plugin.json
├── skills/link-node-modules/
│ ├── SKILL.md
│ └── scripts/link-node-modules.js
├── assets/logo.svg
├── README.md
└── LICENSE
- 推送到 公开 Git 仓库
- 打开 cursor.com/marketplace/publish 提交仓库链接
- 等待人工审核
参考文档:
- 源目录删除或移动后,目标软链会失效
- 两端 lockfile 不一致时仍可能运行异常;本插件只做目录软链,不负责对齐版本