Reputation: 1417
I've recently installed node.js and I have no idea how to run applications. I installed 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.
Upvotes: 138
Views: 364822
Reputation: 497
In my case, there was a problem with the installation, so I got the .msi file for windows, the installer I meant, run it, but clicked on repair instead
Upvotes: -1
Reputation: 12542
Check the node version by typing in your terminal
node -v
Check the npm version by typing
npm -v
If these commands give you the version numbers for node
and npm
you are good to go with NodeJs
development
Time to test node
Create a Directory by running the command.
mkdir NodeJs
Change your directory to the NodeJs
folder and create a file
touch index.js
Open your index.js
either using vi
or in your favorite text editor.
Type in
console.log('Welcome to NodesJs.')
and save the file.
Navigate back to your saved file in the terminal and type
node index.js
If you see Welcome to NodesJs.
you did a nice job and you are up with NodeJs.
Upvotes: 13
Reputation: 1145
Ctrl + R - to open the command line and then writes:
node -v
Upvotes: 4
Reputation: 9194
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.
Upvotes: 238
Reputation: 17518
(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:
C:\Program Files\nodejs\
or
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.6MBIf you don't have it installed, get it from here https://nodejs.org/en/download/
Upvotes: 13
Reputation: 4997
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
Upvotes: 2
Reputation: 559
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'
Upvotes: 20
Reputation: 994
Please try this command node --version or node -v, either of which should return something like v4.4.5
.
Upvotes: 9