Hello, Node
Part of the Node.js Basics section of Coddy's Node.js journey. Lesson 1 of 24.
So far your JavaScript has run in a browser tab. Node.js runs the same language on a computer or a server, with no browser around it.
A Node program is a .js file. The command node weather.js runs this one, top to bottom:
const city = 'Lisbon';
console.log('Weather for ' + city);
console.log('Sunny, 24 degrees');Each console.log prints one line in the terminal. There is no page, so document and window do not exist here. Everything else you know about JavaScript works.
In this section you build notes.js, a tool that keeps your notes in a file.
Challenge
EasyMake notes.js print two lines:
My Notes0 notes
Press Run. The terminal beside your code runs node notes.js and shows what it printed.
Try it yourself
// Your notes tool starts here.
console.log('Hello, Node!');
All lessons in Node.js Basics
1Running JavaScript on Node
Hello, NodeCommand-Line ArgumentsCommands