Today I Learned

TIL, 2022-10-05

WebDev 101: How to use npm and Yarn

Reference

  • Node - allows you to run JS on your machine without running it in the browser.
    • You can write JS that interacts with your computer in ways your browser cannot, like host a REST web server, write files to the hard drive, interact with the OS.
    • Can interface with C APIs.
  • npm
    • Registry - the servers and databases that host the packages with their specific named packages.
    • The CLI - runs on your computer to install and manage the packages on your local disk.
  • Yarn - it does not host its own registry. If you install a library using yarn, you’ll use the NPM registry and the yarn CLI tool.
  • Using Node
    • node index.js to execute files.
    • nodemon is the library that listens to file changes and restarts the process whenever any of your dependencies change.
  • Do not commit node_modules: It bloats the size of the repository, slows down the cloning of the project, makes it difficult/impossible to do analytics on the code, and removes the potential to install security updates with semver ranges.
  • You do commit package-lock.json, so CI pipelines run the same versions of dependencies you’re utilising on your local machine.

This project is maintained by daryllxd