javascript - node_modules 文件夹是否需要 commit

查看:118
本文介绍了javascript - node_modules 文件夹是否需要 commit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问 题

本人刚开始使用一些npm命令,请问假如使用npm安装了某个包,是否需要 git commit 提交, 例如使用 npm 安装了 bootstrap,然后使用 webpack 打包成单个 bundle.js 文件,那么node_modules文件夹需要提交吗?

产生这个困惑是因为自己练习的过程中观察到npm安装的包文件的体积都较大(node_modules文件夹体积比自己工作的主要两个文件index.html和main.js体积大多了)

另外,例如gulpfile.js,pack.json, webpack.config.js 等等这些文件需要提交吗?
关于开发过程中某个文件是否提交,有何方法论可以说说?
望大神不吝赐教。

解决方案

当然不需要提交,因为这些文件,可以通过 package.json 很方便再次下载。

如果你是 git 的话,可以在根目录上加一个 .gitignore 文件,内容:

# See http://help.github.com/ignore-files/ for more about ignoring files.

# compiled output
/dist
/tmp

# dependencies
/node_modules

# IDEs and editors
/.idea
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# IDE - VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json

# misc
/.sass-cache
/connect.lock
/coverage/*
/libpeerconnection.log
npm-debug.log
testem.log
/typings

# e2e
/e2e/*.js
/e2e/*.map

#System Files
.DS_Store
Thumbs.db

这篇关于javascript - node_modules 文件夹是否需要 commit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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