How to Install Grunt on Ubuntu 22.04 & 20.04

Grunt is a node-based task runner that helps developers automate common tasks during the software development process. It can be used to compile code, run tests, and more. grunt is easy to install and configure, and it can be used with any programming language.

Grunt is available as a free, open-source tool, that is typically used in conjunction with other tools, such as Git and npm. A grunt is a powerful tool that can help developers save time and improve their workflow.

In this blog post, you will learn to install Grunt on Ubuntu systems.

Prerequsities

Assuming you already have Node.js and NPM installed on your system. Otherwise, you can visit our other tutorial to install Node.js on Ubuntu systems.

Verify the Node.js and NPM versions:

node --version 
npm  --version 

Installing Grunt CLI

Once you have verified that Node.js and NPM are on your system. Use the following command to install Grun CLI on your system globally.

npm install grunt-cli --location=global 

After successfully installation, check the installed version of Grunt-cli:

grunt --version 
Output
grunt-cli v1.4.3

Now, you add the "scripts": { "test": "grunt test" } to the package.json. Now, run “npm test” to initiate the grun test command.

Enable Shell Auto-completion

You can also enable the tab auto-completion for Grunt, and add one of the following lines to your ~/.bashrc or ~/.zshrc file based on your active shell.

  • Bash shell users edit ~/.bashrc and apped the following code
    eval "$(grunt --completion=bash)"
  • Zsh shell users edit ~/.zshrc and apped the following code
    eval "$(grunt --completion=zsh)"

Conclusion

In this tutorial, you have learned to install Grunt-CLI on your Ubuntu system. Also configured the tab auto-completion.

The post How to Install Grunt on Ubuntu 22.04 & 20.04 appeared first on TecAdmin.

grunt grunt-cli node.js Nodejs npm TecAdmin