curriculum/challenges/english/blocks/review-node-js-intro/69008f1895af88fc335cb0b6.md
Browser Global Object (window): Provides access to browser-related functionalities:
Node.js Global Object (global): Provides access to Node.js specific functionalities:
Single Language for Full-Stack: You can implement both the front-end and the back-end of a web application using JavaScript.
Non-Blocking, Event-Driven Architecture: Great for developing real-time applications where responsiveness and efficiency are essential for creating a good user experience.
Single Thread and Event Loop: Can effectively handle a large number of simultaneous requests and Input-Output operations.
Large Community: Thousands of developers around the world constantly maintain Node.js and add new features.
npm (Node Package Manager): A powerful tool that allows you to install and manage packages and modules for your projects.
Cost-Effective: Node.js is free and open source.
Single-Threaded Limitation: Only runs one thread at a time, meaning it can only handle one operation at a time.
Asynchronous Programming: Node.js relies on asynchronous programming.
Package Quality Concerns: When choosing packages from npm, some may not be constantly maintained and may introduce vulnerabilities into your application.
xcode-select --install
xcode-select --version
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
wget -qO- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
Terminal Restart: You might need to restart your terminal when the process is completed to load the new command and configuration.
Verify NVM Installation:
nvm -v
nvm install --lts
LTS (Long-Term Support): This version is usually recommended because it prioritizes stability, reliability, and security over new or experimental features.
Install Specific Version: You can install a specific version of Node.js by specifying the version number:
nvm install <version>
Example:
nvm install 20
nvm use <version>
Example:
nvm use 20
node -v
Official NVM Support: Official versions of NVM only support Windows in specific cases.
nvm-windows: A Node.js version management utility for Windows.
Before Installing: It is recommended to uninstall any prior Node installation before installing NVM for Windows.
Installation Steps:
https://github.com/coreybutler/nvm-windows/releases.Terminal Restart: You might need to restart your terminal if the nvm command is not immediately available.
Verify Installation:
nvm -v
nvm install lts
nvm install <version>
Example:
nvm install 20
nvm use <version>
Example:
nvm use 20
node -v
nvm-windows. Alternative commands for nvm-windows are provided when possible.Default Execution Policy: PowerShell's default execution policy is Restricted, which prevents scripts from running as a security measure.
Run PowerShell as Administrator: Right-click on PowerShell, then click "Run as Administrator".
Check Current Execution Policy:
Get-ExecutionPolicy
npm to run:Set-ExecutionPolicy RemoteSigned
nvm ls
nvm alias default <version>
Example:
nvm alias default 22.20.0
nvm alias <new_name> <version>
Example:
nvm alias new-api 18.20.8
nvm use <new_name>
Example:
nvm use new-api
nvm uninstall <version>
Example:
nvm uninstall 20.19.5
uninstall command with a major version like 22 or 20:nvm uninstall 20
If you have multiple releases for that major version installed, like 20.14.0 and 20.12.2, the latest version will be removed first. Running nvm uninstall 20 will remove 20.14.0 first.
node -v
npm: A package manager for Node.js used to install, publish, and manage software packages. Automatically installed when you install Node.js.
Check npm Version:
npm -v
node <file.js>
Example:
node app.js
package.json file that tracks its details and dependencies:npm init
Interactive Setup: The npm init command walks you through an interactive CLI guide for setting up the package.json file.
Default Setup: To start with a default package.json file:
npm init -y
or
npm init --yes
npm install <package>
Example:
npm install express
package.json file of a project:npm install
Review the Node JS introductory topics and concepts.