How to tell if node.js is installed or not

Go To StackoverFlow.com

87

I've done a bit of searching, to find the usual, not much, I can't find the "Node.js for dumbies" guide anywhere too.(teehee)

So anyways, down to business.

I've recently install node.js to start making some applications, first encountered problem: no idea how to run applications. All I did was install node.js but couldn't find further instructions. What does one really need to do? I wanted to see if it was actually working. So I executed a script called hello.js it went as such:

console.log('hello world');

Now where would this be logged to?

Edit

I'm running this .js through a .php script.

2012-05-07 01:14
by user1340052
Hmm, I'm using Windows and I open cmd, node is in the system path so if you type node -v you should see the version. Mine is 0.6.15. Running node hello.js, the console.log just prints to the command prompt. In Mac and Linux I think you would just use the terminal and do the above - Tina CG Hoehr 2012-05-07 01:19
My mistake, I forgot to mention that a php script is executing this - user1340052 2012-05-07 01:23
I got confused by the word "terminal". For naive users like me, it is nothing but "command prompt" in windows machines. Run -> Type cmd -> Command Prompt windows appear -> type node --version. You should see version number - now he who must not be named. 2016-01-11 10:06
Btw it ain't "dumbies" it's dummie - avneet 2018-04-12 10:09


164

Open a terminal window. Type:

node -v

This will display your nodejs version.

Navigate to where you saved your script and input:

node script.js

This will run your script.

2012-05-07 01:18
by Piotr Tomasik
My mistake, I forgot to mention I am running this through a php script. So where then will it be printed if not by terminal - user1340052 2012-05-07 01:38
@user1340052, exec() returns the last line from the output, so you should be fine there. http://php.net/manual/en/function.exec.ph - Brad 2012-05-07 02:37
For node and command line newbies, like me who just wasted an hour at node blogs, the phrase "open a terminal window" means do 1 of 2 things in Windows. Either use the Start button, go to Accessories, click Command Prompt; or in the Start button, go to All Programs, then the Node directory, then Node.js Command Prompt. Node has changed and a lot of blogs are way out of date, or just plain obscure about Windows. Hope this saves you an hour - Mike_Laird 2014-03-04 19:45
how can I know if I have a 32-bit or a 64-bit - Francisco Corrales Morales 2014-03-23 20:11
Your OS is either 32-bit or 64-bit. When you install nodejs it picks the matching version - arikin 2015-04-02 07:50


10

open a terminal and enter

node -v

this will tell you the version of the nodejs installed, then run nodejs simple by entering

node

Prompt must be change. Enter following,

function testNode() {return "Node is working"}; testNode();

command line must prompt the following output if the installation was successful

'Node is working'
2016-08-23 14:46
by mehmet riza oz


8

Please try this command node --version or node -v, either of which should return something like v4.4.5.

2016-01-05 05:37
by shijinmon Pallikal
I have nodejs 5.6.0 installed and running "nodejs -version" through terminal returned "command not found". "node -v" is the correct command - markp3rry 2016-02-18 13:17


5

(This is for windows OS but concept can be applied to other OS)

Running command node -v will be able to confirm if it is installed, however it will not be able to confirm if it is NOT installed. (Executable may not be on your PATH)

Two ways you can check if it is actually installed:

  1. Check default install location C:\Program Files\nodejs\

or

  1. Go to System Settings -> Add or Remove Programs and filter by node, it should show you if you have it installed. For me, it shows as title:"Node.js" and description "Node.js Foundation", with no version specified. Install size is 52.6MB

If you don't have it installed, get it from here https://nodejs.org/en/download/

2017-12-12 20:15
by James Wierzba
When I type node -v, a prompt opens and closes quickly. Node is def installed but based on other answers I'm expecting to be able to read something. How do I keep the prompt open - wazz 2017-12-27 21:06
@wazz That definitely shouldn't happen, perhaps your install is corrupted some how? Are you using windows? If so use control panel to uninstall, and then reinstall stable versio - James Wierzba 2017-12-28 06:25
major facepalm. i didn't open cmd. i just typed into the 'run' dialog...tnx - wazz 2017-12-28 06:55
could someone tell me the windows command to see the folder that node is installed in? The equivalent command of "which node" on Ma - santoshbhaskark 2018-02-15 12:30


2

Check the node version using node -v. Check the npm version using npm -v. If these commands gave you version number you are good to go with NodeJs development

Time to test node

Create a Directory using mkdir NodeJs. Inside the NodeJs folder create a file using touch index.js. Open your index.js either using vi or in your favourite text editor. Type in console.log('Welcome to NodesJs.') and save it. Navigate back to your saved file and type node index.js. If you see Welcome to NodesJs. you did a nice job and you are up with NodeJs.

2016-05-31 09:15
by Abdullah Khan


2

Open the command prompt in Windows or terminal in Linux and Mac.Type

node -v

If node is install it will show its version.For eg.,

v6.9.5

Else download it from nodejs.org

2017-03-14 10:02
by Siva Prakash


2

Ctrl + R - to open the command line and then writes:

node -v
2018-11-20 15:35
by Bacar Pereira
Ads