How to automatically clean a node_modules director

2019-04-10 09:47发布

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.

I also wants to commit those dependencies with my project.

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.

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

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.

1条回答
Luminary・发光体
2楼-- · 2019-04-10 10:29

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.

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

查看更多
登录 后发表回答