2
votes

I tried to use many different Vagrant Boxes which I found here. I tried:

  • hashicorp/precise64
  • ubuntu/trusty32
  • ubuntu/trusty64
  • ubuntu/xenial64

but when I try to install latest Node.js (7.5) with (I found this on Installing Node.js via package manager):

curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -

I always get error like this:

Your distribution, identified as "precise", is not currently supported, please contact NodeSource at https://github.com/nodesource/distributions/issues if you think this is incorrect or would like your distribution to be considered for support

I also tried to download ISO image for latest Ubuntu server and install it in VirtualBox manually and in that case installation of latest Node.js works fine. Which Vagrant Box should I use?

Additionally I use Mac OS with VirtualBox to run Vagrant.

My Vagrant config file:

Vagrant.configure(2) do |config|

    config.vm.box = "ubuntu/trusty64"
    config.vm.network :forwarded_port, guest: 80, host: 8080
    config.vm.network "forwarded_port", guest: 3306, host: 3309

end
2
ubuntu/trusty64 will work - I am using both trusty and xenial and they work. how is your Vagrantfile ?Frederic Henri
@FrédéricHenri I updated question description.Luka Lopusina

2 Answers

2
votes

The problem is with version of Linux when I ssh to machine it's not enough to do:

sudo apt-get update
sudo apt-get upgrade

I must also do:

do-release-upgrade

After that installation of latest Node.js goes well.

EDIT 5 January 2018

Vagrantfile:

Vagrant.configure(2) do |config|
    config.vm.box = "ubuntu/trusty64"
    config.vm.network :forwarded_port, guest: 80, host: 8000
    config.vm.provision :shell, :path => ".provision/bootstrap.sh"
end

.provision/bootstrap.sh:

#!/usr/bin/env bash

# update
sudo apt-get update
sudo apt-get -y upgrade

sudo apt-get -y install software-properties-common python-software-properties
sudo apt-get update

# install packages
sudo apt-get -y install curl git

# nginx
sudo apt-get -y install nginx
sudo service nginx start

# remove default nginx config
sudo rm /etc/nginx/sites-enabled/default

# set up nginx server
sudo cp /vagrant/.provision/nginx/nginx.conf /etc/nginx/sites-available/site.conf
sudo chmod 644 /etc/nginx/sites-available/site.conf
sudo ln -s /etc/nginx/sites-available/site.conf /etc/nginx/sites-enabled/site.conf
sudo service nginx restart

# clean /var/www
sudo rm -Rf /var/www

# symlink /var/www => /vagrant
sudo ln -s /vagrant /var/www

# Node
curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs

sudo apt-get install -y build-essential

nginx/nginx.conf:

server {
    listen 80;

    server_name todo.dev;
    access_log /var/log/nginx/access.log;
    error_log /var/log/nginx/error.log;

    root   /var/www/dist;
    index index.html index.htm;

    location / {
        try_files $uri $uri/ /index.html;
    }

}

Keep in mind that this was older version of node 6.x but you will probably only need to switch url in bootstrap.sh script to newer version. I don't use Vagrant anymore (instead I use Docker now) so I am not up to date with it.

0
votes

well the following works for me and install nodejs

Vagrant.configure(2) do |config|

    config.vm.box = "ubuntu/trusty64"
    config.vm.network :forwarded_port, guest: 80, host: 8080
    config.vm.network "forwarded_port", guest: 3306, host: 3309

    config.vm.provision :shell, :inline => "curl -sL https://deb.nodesource.com/setup_7.x | bash - && apt-get -y install nodejs"

end

node gets installed as part of the initial provisioning

vagrant@vagrant-ubuntu-trusty-64:~$ node --version
v7.5.0