Setting Up the Development Environment

Topic Outline (30-min)

  1. Installing Node.js (macOS, Windows, Linux):

    • Windows:

      1. Download the installer from nodejs.org.

      2. Follow the installation wizard and ensure npm is installed alongside.

      3. Verify installation:

        bash코드 복사node -v
        npm -v
    • macOS:

      1. Use Homebrew: brew install node.

      2. Verify installation as above.

    • Linux:

      1. Use curl to 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 nodejs
      2. Verify installation.

  2. 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 | bash
    • Restart the terminal and verify:

      bash코드 복사nvm --version
    • Install and use Node.js:

      bash코드 복사nvm install 18
      nvm use 18
  3. Node.js REPL for Quick Experimentation:

    • Access the REPL (Read-Eval-Print Loop):

      bash코드 복사node
    • Test a few commands:

      javascript코드 복사console.log('Hello, REPL!');
      let a = 10;
      let b = 20;
      a + b;
  4. 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.js
    • Open Chrome and navigate to chrome://inspect, then click on "inspect" under Remote Target.

  5. Verifying and Troubleshooting Installations:

    • Check installed Node.js and npm versions:

      bash코드 복사node -v
      npm -v
    • Common issues:

      • Problem: node command not found. Solution: Ensure Node.js is added to your system PATH.

Last updated