如何为 SCM 提交自动清理 node_modules 目录 [英] How to automatically clean a node_modules directory for a SCM commit

查看:28
本文介绍了如何为 SCM 提交自动清理 node_modules 目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 node.js 很陌生.将我的依赖项(来自 node_modules)放在我的项目适合我的同一目录中的功能.

I am quite new with node.js. The feature of having my dependencies (from node_modules) in the same directory that the one of my project suits me.

我还想在我的项目中提交这些依赖项.

我从一个使用 socket.io 的项目开始.但是当我在 npm install socket.io 之后查看 npm 生成的目录时,有示例文件、文档、自述文件、基准数据、更改日志、... 很多我不想在我的 git 或 subversion 系统中提交的文件.

I started with a project that uses socket.io. But when I take a look at the directory generated by npm after a npm install socket.io, there are examples files, documentation, readme files, benchmark data, changelogs, ... Lots of files that I do not want to commit in my git or subversion system.

是否有一种自动工具可以缩小 node_modules 目录的内容以仅保留需要的内容?

Is there an automatic tool that shrinks the content of a node_modules directory to only keep what is needed?

如果我正确阅读了 npm 的文档,我将一无所获.有一个 prune 选项,但是它是删除未使用的依赖项.

If I read correctly the documentation of npm, I found nothing for that. There is a prune option, but it is to remove the unused dependencies.

推荐答案

不,没有工具可以做到这一点.通常,模块的作者使用 .npmignore 来忽略他不想发布的任何文件.几乎所有作者都发布了示例、文档、自述文件、变更日志.

No, there is not tool to do that. Generally the author of the module uses .npmignore to ignore any files which he doesn't want published. Examples, Docs, Readme, Changelogs are published by almost all authors.

你唯一的方法是删除它们并提交到 git.

The only way for you is to delete them and commit to git.

这篇关于如何为 SCM 提交自动清理 node_modules 目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆