Home › JavaScript Tutorial › JavaScript installation
JavaScript installation
Full step-by-step installation for Windows, macOS and Linux.
Step 1: Install a code editor
- Open
code.visualstudio.comand click the Download button for your system. - Windows: run the installer, accept the agreement and tick Add to PATH and Open with Code. macOS: open the downloaded zip and drag Visual Studio Code into the Applications folder. Linux: run
sudo snap install code --classicor install the .deb file. - Open VS Code once to make sure it starts.
Step 2: Try JavaScript in the browser
- Open any web page in Chrome or Edge.
- Press F12 and click the Console tab.
- Type
console.log("Hello")and press Enter to see the result.
Step 3: Run JavaScript from a file
- Create
index.htmlin a folder and open the folder in VS Code. - Add a
<script>tag before</body>and paste the code from the editor below. - Save, double-click the file and look at the page. Errors appear in the Console.
Optional: install Node.js
- Download the LTS version from
nodejs.organd run the installer with the default options. - Open a new terminal and run
node -vto check it. - Run a file with
node app.js.
If something goes wrong
- Nothing happens: open the Console (F12) and read the red error message.
nodeis not recognized: close and reopen the terminal, or reinstall Node.js.
Commands in this lesson
console.log
Definition: Prints a value for debugging.
Syntax:
console.log(value);
Example:
console.log("Sum:", 2 + 3);Example code
<p id="o"></p>
<script>
document.getElementById("o").textContent = "JavaScript is working";
</script>