Setting Up the Development Environment
Topic Outline (30-min)
Installing Node.js (macOS, Windows, Linux):
Windows:
Download the installer from nodejs.org.
Follow the installation wizard and ensure
npmis installed alongside.Verify installation:
bash코드 복사node -v npm -v
macOS:
Use Homebrew:
brew install node.Verify installation as above.
Linux:
Use
curlto install Node.js from the official repositories:bash코드 복사curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - sudo apt-get install -y nodejsVerify installation.
Using Node Version Manager (nvm) for Managing Versions:
Install
nvm:bash코드 복사curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.4/install.sh | bashRestart the terminal and verify:
bash코드 복사nvm --versionInstall and use Node.js:
bash코드 복사nvm install 18 nvm use 18
Node.js REPL for Quick Experimentation:
Access the REPL (Read-Eval-Print Loop):
bash코드 복사nodeTest a few commands:
javascript코드 복사console.log('Hello, REPL!'); let a = 10; let b = 20; a + b;
Debugging Node.js Applications Using Chrome DevTools:
Add the following script to
debug.js:javascript코드 복사let a = 10; let b = 20; debugger; console.log(a + b);Run the script in debug mode:
bash코드 복사node inspect debug.jsOpen Chrome and navigate to
chrome://inspect, then click on "inspect" under Remote Target.
Verifying and Troubleshooting Installations:
Check installed Node.js and
npmversions:bash코드 복사node -v npm -vCommon issues:
Problem:
nodecommand not found. Solution: Ensure Node.js is added to your system PATH.
Last updated