Have you ever been inside of terminal and said to yourself, "I wish I could play a quick game of Pong." Yeah, me either, but if that ever comes up, here are 5 cool games that you can install with NPM and play directly in your terminal.
1. Pong ๐
The beloved pong game where you smack a ball back and forth can easily be installed in your terminal with the following command:
npm i -g command-line-pong
After installing it globally, you can run the following command:
pong
And you'll be able to play a game of pong. Take a look at the quick example below.
{% asciinema vMGAvwlI5Q3tQCmnlnYuQxFcG %}
You can find this npm package here: https://www.npmjs.com/package/command-line-pong
2. Snake ๐
Next up is the addictive and sometimes boring snake game. You can play a quick game of snake by running the following NPM command:
npm i -g command-line-snake
Then, you can run the following command:
snake
Take a look at how the game looks below.
{% asciinema BpC5dK7d1fcKQIO85oMP8MO9v %}
You'll find this NPM package located at https://www.npmjs.com/package/command-line-snake
3. Minesweeper ๐ฃ
This next game is the bomb! Well, maybe not, but if you play it, you will probably uncover a bomb. You can easily play a mind-puzzling game of minesweeper by cloning the GitHub repo:
git clone https://github.com/ChalkPE/node-minesweeper.git
Then, you'll need to go into that directory and run the npm dependencies:
cd node-minesweeper && npm install && npm start
And you'll be playing minesweeper just like that.
{% asciinema K8gT3rf4IJTO8LQAerWCndowN %}
You can find this NPM game at https://www.npmjs.com/package/node-minesweeper
4. Battleship ๐ข
Next, if you're ready to blow up some ships in an epic game of battleship, you can do so by installing this NPM game with the following command:
npm i battleship-game -g
Then, run:
battleship-game
And you'll be blowing ships up in your terminal (or missing them).
{% asciinema xeJdOGbNLSxb38I2ZBUD9LJav %}
You can find this NPM package at https://www.npmjs.com/package/battleship-game
5. Blackjack โ ๏ธ
Last but not least! You can play a quick game of blackjack in between a git push by running the following command in a new folder:
npm i node-blackjack
Next, you can run the following command to play a quick game:
touch index.js && echo "require('node-blackjack')" >> index.js && node index.js
{% asciinema 2b00SGx8QKd0PQRZT7oXuT8Gn %}
You can find this NPM package located at https://www.npmjs.com/package/node-blackjack
Conclusion
That's the round-up of 5 simple NPM CLI based games you can add to spice up your terminal.
I hope you found these games useful (or distracting) ๐ค