Cyberithub

How to Install Grunt on Ubuntu 20.04 LTS Using 5 Easy Steps

Advertisements

In this article, I will take you through the steps to install grunt on Ubuntu 20.04 LTS. Grunt is a JavaScript task runner tool which is used to perform automation tasks like minification, compilation, unit testing, and linting. You can almost perform all your repetitive tasks using Grunt task runner. You just need to configure a Gruntfile and that's it !!

Although Grunt plugins has almost all the tasks available that you need but in case something remains you can write your own grunt plugin and publish it to npm for further use without any hiccups. There are other useful features Grunt task runner provides which can be checked on its official website. Here I am going to show you the steps to install Grunt on Ubuntu 20.04 LTS in great detail.

Advertisements

How to Install Grunt on Ubuntu 20.04 LTS Using 5 Easy Steps

How to Install Grunt on Ubuntu 20.04 LTS Using 5 Easy Steps

Also Read: Error "activation of network connection failed" on Linux

Step 1: Prerequisites

a) You should have a running Ubuntu 20.04 LTS Server.

Advertisements

b) You should have sudo or root access to run privileged commands.

c) You should have apt utility available in your System.

Advertisements

 

Step 2: Update Your Server

First you need to update your Server by using sudo apt update command as shown below. If any of the packages needs to be upgraded then run sudo apt upgrade command as well.

cyberithub@ubuntu:~$ sudo apt update
Hit:1 http://in.archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://in.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:3 http://in.archive.ubuntu.com/ubuntu focal-backports InRelease
Get:4 https://dl.google.com/linux/chrome/deb stable InRelease [1,811 B]
Get:5 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:6 https://dl.google.com/linux/chrome/deb stable/main amd64 Packages [1,093 B]
Get:7 http://security.ubuntu.com/ubuntu focal-security/main i386 Packages [472 kB]
Get:8 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [1,632 kB]
Get:9 http://security.ubuntu.com/ubuntu focal-security/main Translation-en [277 kB]
Get:10 http://security.ubuntu.com/ubuntu focal-security/main amd64 DEP-11 Metadata [40.7 kB]
Get:11 http://security.ubuntu.com/ubuntu focal-security/main amd64 c-n-f Metadata [10.8 kB]
Get:12 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [1,092 kB]
Get:13 http://security.ubuntu.com/ubuntu focal-security/restricted Translation-en [155 kB]
Get:14 http://security.ubuntu.com/ubuntu focal-security/universe i386 Packages [557 kB]
Get:15 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [711 kB]
Get:16 http://security.ubuntu.com/ubuntu focal-security/universe amd64 DEP-11 Metadata [66.9 kB]
Get:17 http://security.ubuntu.com/ubuntu focal-security/universe amd64 c-n-f Metadata [14.7 kB]
Get:18 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 DEP-11 Metadata [2,464 B]
Fetched 5,149 kB in 4s (1,373 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done

 

Step 3: Install Node.js

Since Grunt task runner is required for Node.js projects, so first we need to have Node.js installed in our system. You can install Node.js from default Ubuntu repo by using sudo apt install nodejs command as shown below. This will download and install the package along with all its dependencies.

Advertisements
cyberithub@ubuntu:~$ sudo apt install nodejs
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
libfwupdplugin1
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
libc-ares2 libnode64 nodejs-doc
Suggested packages:
npm
The following NEW packages will be installed:
libc-ares2 libnode64 nodejs nodejs-doc
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 6,807 kB of archives.
After this operation, 30.7 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
............................................

After successful installation, you can check the node version by using node --version command as shown below.

cyberithub@ubuntu:~$ node --version
v10.19.0

 

Step 4: Install NPM

Since all the plugins and tools in Node.js are managed by NPM, we need to first install the NPM tool to install the Grunt plugin. You can simply run sudo apt install npm command to download and install the package from default Ubuntu repo as shown below.

cyberithub@ubuntu:~$ sudo apt install npm
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following package was automatically installed and is no longer required:
libfwupdplugin1
Use 'sudo apt autoremove' to remove it.
The following additional packages will be installed:
binutils binutils-common binutils-x86-64-linux-gnu build-essential dpkg-dev fakeroot g++ g++-9 gcc gcc-9 gyp javascript-common libalgorithm-diff-perl
libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan5 libatomic1 libbinutils libc-dev-bin libc6-dev libcrypt-dev libctf-nobfd0 libctf0 libfakeroot
libgcc-9-dev libitm1 libjs-inherits libjs-is-typedarray libjs-psl libjs-typedarray-to-buffer liblsan0 libnode-dev libpython2-stdlib libpython2.7-minimal
libpython2.7-stdlib libquadmath0 libssl-dev libstdc++-9-dev libtsan0 libubsan1 libuv1-dev linux-libc-dev make manpages-dev node-abbrev node-ajv node-ansi
node-ansi-align node-ansi-regex node-ansi-styles node-ansistyles node-aproba node-archy node-are-we-there-yet node-asap node-asn1 node-assert-plus
node-asynckit node-aws-sign2 node-aws4 node-balanced-match node-bcrypt-pbkdf node-bl node-bluebird node-boxen node-brace-expansion node-builtin-modules
node-builtins node-cacache node-call-limit node-camelcase node-caseless node-chalk node-chownr node-ci-info node-cli-boxes node-cliui node-clone node-co
node-color-convert node-color-name node-colors node-columnify node-combined-stream node-concat-map node-concat-stream node-config-chain node-configstore
node-console-control-strings node-copy-concurrently node-core-util-is node-cross-spawn node-crypto-random-string node-cyclist node-dashdash node-debug
node-decamelize node-decompress-response node-deep-extend node-defaults node-define-properties node-delayed-stream node-delegates node-detect-indent
........................................

After successful installation, you can check the npm version by using npm --version command as shown below.

cyberithub@ubuntu:~$ npm --version
6.14.4

 

Step 5: Install Grunt CLI

Finally, you can install Grunt CLI from npm package manager by using sudo npm install -g grunt-cli command as shown below.

cyberithub@ubuntu:~$ sudo npm install -g grunt-cli
/usr/local/bin/grunt -> /usr/local/lib/node_modules/grunt-cli/bin/grunt
+ grunt-cli@1.4.3
added 59 packages from 71 contributors in 4.488s

Leave a Comment