拉代码后npm i 提示代码更改9999+是因为创建代码仓库把node_modules文件提交到了git仓库

如图所示:将仓库代码拉下来后下载依赖包 npm i 显示更改 9999+,打开一看发现全是node_modules文件相关的。

以下是我的详细解决方案:

第一步:首先在根目录下的.gitignore文件中写入node_modules/,确保下次提交排除node_module文件夹

.gitignore文件的作用就是用来加入需要忽略的文件名,这里我还写了其他的文件,大家可以按需添加。注意node_module是文件夹,一定要在后方加上 / 斜杠,否则无效

第二步:将node_modules从 git 追踪中删除,命令如下 git rm -r --cached node_modules (执行这一步是因为远程的代码仓库里面已经存在了node_modules,如果远程代码仓库没有node_modules就不需要做这一步操作)

第三步:重新提交

git add . 
git commit -m'remove node_modules文件夹'
git push 

这样问题就解决啦!代码仓库的node_modules文件也就被删除了,后续更新也不会将node_modules再次推上去

猜你喜欢

转载自blog.csdn.net/weixin_73318685/article/details/132880728
今日推荐