How to Install Grunt and Grunt-cli on Ubuntu 16.04

To Install Grunt and Grunt-cli on Ubuntu 16.04

Grunt is a JavaScript task runner, which helps in performing repetitive tasks like compilation, unit testing, and linting. This means that a developer can save time and spend it doing more useful development work. It is so simple to install both Grunt and Grunt-cli on Ubuntu 16.04, and this tutorial sheds light on the same process. 

Installing Grunt

Grunt and Grunt plugins are installed and managed via the Node.js package manager, npm. So, the first thing to do is install Node.js. Node.js is available in the Ubuntu repository, with its required dependencies. You can install Node.js with the help of the following command.

root@linuxhelp:~# apt install nodejs npm
Reading package lists... Done
Building dependency tree     
Setting up npm (3.5.2-0ubuntu4) ...
Processing triggers for libc-bin (2.23-0ubuntu10) ...



And then, check if npm is up to date and running in your system.

root@linuxhelp:~# npm update -g npm


At this point, it’s possible to install Grunt and its CLI. Both of them can be installed by making use of the following command.

root@linuxhelp:~# npm -g install grunt
npm WARN deprecated coffee-script@1.10.0: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
/usr/local/bin/grunt -> /usr/local/lib/node_modules/grunt/bin/grunt
+-- path-is-absolute@1.0.1 
  `--  rimraf@2.2.8


root@linuxhelp:~# npm -g install grunt-cli
loadDep:path-is-absolute   |####################-------------------------------------------------------------------------
+-- nopt@3.0.6 
  | `-- abbrev@1.1.1 
  `-- resolve@1.1.7  


A Grunt setup involves adding package.json and Gruntfile to the project. So, let us create a new project to test that. Create a new folder first, by making use of the following command.

root@linuxhelp:~# mkdir ~/grunt_project



In this folder, you need to execute this action.

root@linuxhelp:~# npm init 
This utility will walk you through creating a package.json file.
Use `npm install <pkg> --save` afterwards to install a package and
save it as a dependency in the package.json file.

Then, you should give all the essential information about the project name, author, a git repository, version, etc. And then, you need to Enter and it will create a package.json file with all of the information you entered.

With this, the installation of Grunt and Grunt-cli on Ubuntu 16.04 comes to an end. 

Thank you! for using Linux Help.

You find this tutorial helpful? Share with your friends to keep it alive.
For more help topics browse our website
Be the first to comment, we value your suggestions. For further queries please comment below.

Tags: Ubuntu
user image Author :  Jackson