如何在 vagrant rsync 中排除(忽略)某些文件夹? [英] How to exclude (ignore) certain folders in vagrant rsync?

查看:27
本文介绍了如何在 vagrant rsync 中排除(忽略)某些文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望在我的 vagrant virtual box 中运行 npm install.

I wish to run npm install in my vagrant virtual box.

但是每当我运行 npm install 命令时,我的 rsync 就会执行.由于我的主机没有安装 node_modules,它只是为我完全删除了文件夹.

But whenever I ran the npm install command, my rsync will execute. Since my host computer does not have node_modules installed, it simply remove the folder completely for me.

我需要做什么才能让我的 vagrant rsync 忽略 node_modules 文件夹?

What do I need to do so that my vagrant rsync will ignore the node_modules folder?

我无法将 node_modules 同步到来宾计算机,因为我的主机和来宾是两个不同的系统.到目前为止,我的 vagrantfile 看起来像这样.

I cannot have node_modules being rsynced into the guest machine because my host and guest are two different systems. So far my vagrantfile looks like this.

Vagrant.configure("2") do |config|
  config.vm.box = "laravel/homestead"

  config.vm.hostname = "localhost"

  config.vm.network "forwarded_port", guest: 8000, host: 8000

  config.vm.synced_folder "./", "/home/vagrant/app"

  config.vm.provider "virtualbox" do |v|
    v.name = "web2"
    v.memory = "4096"
    v.cpus = 2
    v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/SHARE_NAME", "1"]
  end

  config.vm.synced_folder "./", "/home/vagrant/app", type: "rsync", rsync_auto: true, rsync_exclude: ['node_modules*']
  config.vm.provision :shell, path: "provision/setup.sh"

end

我通过

vagrant rsync-auto

推荐答案

rsync__exclude 以及 rsync__auto 需要 2 _

您需要将您的行重写为

config.vm.synced_folder "./", "/home/vagrant/app", type: "rsync", rsync__auto: true, rsync__exclude: ['./node_modules*']

这篇关于如何在 vagrant rsync 中排除(忽略)某些文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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