How to install Truffle & TestRPC on Ubuntu or Windows 10 with “Windows subsystem for Linux”

I previously wrote how you can install Truffle & TestRPC on a windows machine, by using the Windows installers for Node & npm.
However I have found it is a much nicer experience to use the Windows Subsystem for Linux which provides a native Ubuntu shell with bash, which allows me to run all the Linux tools natively without issues. These install steps will work on an Ubuntu machine as well.

Prerequisite if running on Windows

  1. Enable Windows subsystem for Linux and install from Windows Store.Follow this short guide on how to enable it https://msdn.microsoft.com/en-us/commandline/wsl/install_guide 
  2. After following the steps in the guide above. Simply start the Ubuntu bash shellubuntu start

Install steps

Clean install on a machine without node

# (optional) Make sure Ubuntu is up to date
sudo apt-get update -y && sudo apt-get upgrade -y

# install nvm  https://github.com/creationix/nvm#install-script
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.6/install.sh | bash

# restart bash to reload the path for nvm
exec bash

# install node and our npm packages
nvm install node
npm install -g truffle ethereumjs-testrpc

Install on a machine with node installed via nvm
You need at least node v8+ and npm 5.3.0+ (latest is better). you can check this with node -v; npm -v

# update nvm then install the tools
nvm install node

npm install -g truffle ethereumjs-testrpc

Another option if you have Node already installed is to use the dist-upgrade package

# Install the dist-upgrade package and run it to update to the latest node version
sudo npm -g install dist-upgrade
sudo dist-upgrade

npm install -g truffle ethereumjs-testrpc

 

now you should be able to create a folder, go into it and run `truffle init` to create a new project template.

imageimage

Additional things to do

Now that your machine has it installed, I recommend you follow my other guide to get Visual Studio code configured for Truffle development.

Advertisements

5 thoughts on “How to install Truffle & TestRPC on Ubuntu or Windows 10 with “Windows subsystem for Linux”

  1. […] UPDATE 2017/08/25: Now that Truffle has made installation easier, I have cleaned up and streamlined the windows install steps below.However I recommend that instead look at using the new feature in Windows 10 that lets you run Linux tools directly in Windows. This is how I’ve been doing my development for the last few months https://davidburela.wordpress.com/2017/05/12/how-to-install-truffle-testrpc-on-ubuntu-or-windows-10-… […]

  2. Hello David, finally I´ve installed truffle on my W10 machine and I am using an Ubuntu subsystem to run all the Linux tools natively without issues. I have a question (also, I´ve already installed the extension Solidity for Visual Studio Code)…When I create a new folder in truffle (f.e. named “Token”) where is it kept away? Because when I type “code .” in the Ubuntu tool inside the folder, Visual Code is initialized but doesn´t show me the dir of that folder and I can´t code nothing.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s