Your own free linux VM

Cloud Platform (easy level) posted on 23rd Jan 2018


Now that Apps Script is opening up with a new CLI tool and API to allow you to use your own development tool change, there's more reason than ever to start using NodeJs as part of your arsenal, if you are not already. If you are using Windows or a Mac, you can run it locally of course, but if you are using a Chromebook - or prefer to just use your PC as a browser, then it's a little more challenging.

You could hack your Chromebook to run Linux, but why bother when you can get a VM for free. One of the best places to do that (and get a development environment thrown in) is to use Cloud9 (c9.io). Along with many of the Apps Script GDES, that's been my development platform of choice for some time now, but with the introduction of clasp and because most of what I do nowadays involves other Google APIS and data manipulation,  I figured that using something closer to the cloud platform was a better solution. 

You are of course spoilt for choice with the power and type of machines you can provision on Compute Engine, but you can get a micro environment for pretty much free - see Getting cockroachdb running on google cloud platform for an example. 

Micro VM

One of the troubles there is that you'll start to get this pretty soon, as it really is a pretty small machine.

with this recommendation

But a small machine will cost about $15 a month.

The cloud shell

The cloud console (you can also get to it from the Apps Script IDE) comes with what they call a cloud shell, but actually it's a fully functional VM (a small configuration). Here's it is here with 4 terminal sessions open on it - it has 1.7GB memory as per the small configuration VM.

It's running Debian

and it's persistent, so you can load things on it.

You can easily access the cloud shell from your cloud console


and directly from your Apps Script project (note that it's the same machine, regardless of the project)

Limitations

There are of course limitations on what Google want you to do with this handy instance. Read about them here.

Installing Node

Now you can install node and you have your own Linux VM for free that you can use to install Node and play around with clasp for Apps Script.
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.0/install.sh | bash
nvm --version
nvm install node
nvm use node
node
>console.log ('roger that');
roger that
undefined
>.exit
  • There's a bit of a delay where nothing seems to happen at the first stage. Just be patient.
  • You'll see message about closing and opening your terminal session, or executing a command that looks  something like this. This creates some environment variables so you can run nvm to install node
export NVM_DIR="/home/bruce/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \
. "$NVM_DIR/nvm.sh" # This loads nvm

Removing Node and Nvm

If you want to get rid of it, then you can just delete the directories it lives in. 
sudo rm -rf /usr/local/nvm
rm -rf .nvm




Why not join our forum, follow the blog or follow me on twitter to ensure you get updates when they are available.
Comments