怎么设置才能让 npm 不自动清理我的自定义模块?

2017 年 11 月 18 日
 wucancc
我自己写了一个模块放在了 node_modules 文件夹里面,但是每次执行 npm install/yarn 的时候会自动把我的组件给清理了。怎么设置才能不让 npm 自动清理呢?

project
--src
--node_modules
----我的模块
----其他模块
--package.json
4269 次点击
所在节点    Node.js
8 条回复
nightcat
2017 年 11 月 18 日
模块没手动写入 package.json 依赖?
kfll
2017 年 11 月 18 日
推荐 yarn workspace
wucancc
2017 年 11 月 18 日
@nightcat 这个模块是我自己自定义的,请问可以写入 package.json 的依赖吗
pynix
2017 年 11 月 18 日
npm link
Kokororin
2017 年 11 月 18 日
yarn add file:./../your-package
wucancc
2017 年 11 月 18 日
@pynix 非常感谢,用 npm link 解决了
chnwillliu
2017 年 11 月 19 日
excuse me? 自己写的模块为啥要放到 node_modules 里?
wucancc
2017 年 11 月 26 日
@chnwillliu 之前以为独立模块都需要放在 node_modules 里面。。。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://v2ex.xtra.eu.org/t/407438

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX