Netlify CLI
Documenting the installation process for Netlify CLI in Ubuntu 18.04 on WSL 2 in Windows 10 build 2004, in order to develop with Hugo locally, using the same tools we'll use in production.
Windows
- Upgrade Windows 10 Pro to build 2004, particularly because:
With this release, memory that is no longer in use in a Linux VM will be freed back to Windows. Previously, a WSL VM's memory could grow, but would not shrink when no longer needed.
- Update to WSL 2
- Install Ubuntu 18.04 LTS
Set up development
Install Yarn, Node.js, nvm. Instructions adapted from:
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt update
sudo apt install yarn
sudo apt install npm
yarn --version
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
Then, close the terminal and re-open
nvm --version
Check the latest LTS version of Node.js
nvm install 12.18.1
node --version
Install Netlify Dev
npm install netlify-cli -g
Fix metadata on /mnt/c/
, with this post from askubuntu.com
sudo umount /mnt/c
sudo mount -t drvfs C: /mnt/c -o metadata
Check for the latest version of Hugo
Download:
wget https://github.com/gohugoio/hugo/releases/download/v0.73.0/hugo_extended_0.73.0_Linux-64bit.deb
sudo dpkg -i hugo_extended_0.73.0_Linux-64bit.deb
As I've previously mentioned, I use a Go module, so I need to install Go
wget https://dl.google.com/go/go1.14.4.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.14.4.linux-amd64.tar.gz
export PATH=$PATH:/usr/local/go/bin
Then I can run
netlify build --dry
Once I'm happy with that:
netlify build
netlify dev
And then I can read locally with a URL like http://localhost:1313/post/netlify-cli-ubuntu-windows/