Building ionic on vagrant through php exec

I need to set the default alias for node

there is also this I am looking at

I did nvm alias default 8.3.0

Then restarted vagrant.

Still using wrong version

Might editing /home/vagrant/.nvmrc help?

Can’t find that file. Think it is an alias issue.

Two reasons for that. One is that I may be wrong as to where vagrant’s home directory is. Second is that it doesn’t exist unless you make it.

Ok for now I am looking into altering the vagrant / homestead provisioning script.

I might have to continue this conversation on the Laravel forum.

Let me jump in here again and ask why you want to

  • run an Ionic build via npm or CLI
    • inside a shell
      • inside a PHP script
        • (inside a Laravel project?)
          • inside a Laravel Homestead environment
            • inside a vagrant box?

(Typing that was actually fun)

Haha why not?

Vagrant is a virtual environment so I am doing here as I don’t want to do it on a live site.

I use Homestead / Vagrant to run Laravel.

I want to build ionic through node as it has been asked as a requirement for prototyping hybrid apps. I have a preview which runs the web app version. The cms allows for the default sass colours to be altered and set up config variables. It then needs to be built via a script as it is used by people with no programming skills. I never said it would be easy but I know it is possible. It is just a case of finding out why the script is using the wrong node. As I say I am looking into changing the provision script for Vagrant. It also does code push which requires a fresh build.

Once I have this working on my Vagrant Box I will attempt it on a live server.

The application will then be able to quickly almost fully automate the setting up of an app template through php and node.

1 Like

That is a valid answer.

I liked the longer one better, though :wink:

Good luck.

Got the provisioning to work but the script is still using a different version even though it is the same user as what I am logging in as. Not sure how that is possible.

Script is below if anyone is interested.

# install latest nvm
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash

# install latest stable node.js
echo "Installing node.js... (please be patient)"

bash
. ~/.nvm/nvm.sh
nvm

nvm install nvm install 8.3.0
nvm alias default 8.3.0

Finally found the solution to be adding

.’ ~/.nvm/nvm.sh; . ~/.profile; . ~/.bashrc;’ To the start of any scripts requiring node.

2 Likes