I created a VM to work on expo. I can't run Metro Bundle in browser in my host on 19002 port. Vagrantfile:
# -*- mode: ruby -*-
# vi: set ft=ruby :
VAGRANTFILE_API_VERSION = "2"
REACT_NATIVE_PACKAGER_HOSTNAME = Socket.ip_address_list.find { |ai| ai.ipv4? && !ai.ipv4_loopback? }.ip_address
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "geerlingguy/ubuntu1804"
config.ssh.insert_key = false
config.vm.provider :virtualbox do |v|
v.name = "mobile-app"
v.memory = 2048
v.cpus = 1
v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
v.customize ["modifyvm", :id, "--ioapic", "on"]
end
config.vm.synced_folder "./", "/home/vagrant/workspace", type: 'nfs', mount_options: ['nolock,vers=3,udp,noatime']
config.vm.hostname = "mobile-app"
config.vm.network :private_network, ip: "192.168.33.40"
config.vm.network "forwarded_port", guest: 3000, host: 3000
config.vm.network "forwarded_port", guest: 19000, host: 19000
config.vm.network "forwarded_port", guest: 19001, host: 19001
config.vm.network "forwarded_port", guest: 19002, host: 19002
config.vm.network "forwarded_port", guest: 19006, host: 19006
config.vm.provision "shell", path: "install.sh"
config.vm.provision "set_lan_ip", "type": "shell" do |installs|
installs.inline = "
echo 'export REACT_NATIVE_PACKAGER_HOSTNAME=#{REACT_NATIVE_PACKAGER_HOSTNAME}' >> /home/vagrant/.zshrc
"
end
end
When I run npm start
I see information that expo start. I can see url and qr image:
Starting project at /home/vagrant/workspace/app
Expo DevTools is running at http://localhost:19002
Opening DevTools in the browser... (press shift-d to disable)
Starting Metro Bundler
When I run localhost:19002 and 192.168.33.40:19002, I see: This site can’t be reached
. But when I launch expo start:web
and open: 192.168.33.40:19006 works fine... When I run curl localhost:19002
on guest, I can see html, but the same cmd on host gets: Recv failure. (192.168.33.40 the same error).
I checked ports:
node 1116 vagrant 21u IPv4 21603 0t0 TCP 127.0.0.1:19002 (LISTEN)
node 1116 vagrant 22u IPv6 21661 0t0 TCP *:19000 (LISTEN)
node 1160 vagrant 20u IPv6 21720 0t0 TCP *:19001 (LISTEN)
and where web is active:
node 1220 vagrant 22u IPv4 22679 0t0 TCP *:19006 (LISTEN)
I think that it may be a problem with port. 19002 is mapped on localhost(127.0.0.1), but should allowed on all interfaces. Can I set it in expo?
Where is my mistake?
resources: https://github.com/jean553/react-native-dev, Expo and Vagrant
Solution:
export EXPO_DEVTOOLS_LISTEN_ADDRESS=192.168.33.40
I used a other parameter but this one is correct...