Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialStheven Cabral
Full Stack JavaScript Techdegree Graduate 29,854 PointsWhy write 'node' in the console?
Hello All,
Why does the instructor always write node before initializing the .js file? What is the purpose of it?
Is it something that needs to be installed on a personal computer in order to use it?
2 Answers
KRIS NIKOLAISEN
54,971 PointsYou'd run node from BASH. If you are talking about a Mac once installed you can open your terminal and enter the node command. If you leave out the file name you get the node shell in interactive mode. BASH won't understand the code so you would need node. For example from my terminal:
kris$ var a=1;
-bash: var: command not found
kris$ node
> var a=1;
undefined
> a
1
KRIS NIKOLAISEN
54,971 PointsThe command:
node filename.js
executes the file named filename.js using the node shell. Similar to
python filename.py
executing filename.py with the python shell.
You can install node here
Stheven Cabral
Full Stack JavaScript Techdegree Graduate 29,854 PointsDoes it specifically have to be a node shell? Can I use a BASH shell?
Stheven Cabral
Full Stack JavaScript Techdegree Graduate 29,854 PointsStheven Cabral
Full Stack JavaScript Techdegree Graduate 29,854 PointsThank You