Console.log not displaying any output (NodeJs)

Viewed 2820

I am trying to console log a piece of JavaScript code through Node.Js but the terminal is not showing any output.

const pokemon = require('pokemon');
pokemon.all();
var name = pokemon.random();
console.log(name);

Can't even console log a simple line of code

console.log("Hello");

Image of terminal after executing node file

2 Answers

It is possible that you use node which is not a nodejs package but another. If you type node on command line, do you see something like this? Especially the message Welcome to Node.js vxx.xx.x.

hanania@laptop:~$ node
Welcome to Node.js v12.16.3.
Type ".help" for more information.
>

just try to check out if nodejs is installed successfully on your device by runing

node --version

and if it doesn't respond with nodejs version you need to reinstall nodejs

Related