NPM

NPM

notion image
NPM is node’s package manager. A package is some piece of code that can be used again. With NPM we can either create our own packages or use other people packages from npmjs.com. Even big libraries like React or Express are nothing but an npm package

Terminology

  1. The npm CLI tool to add or remove packages
  1. The npmjs.com website that lists all the npm packages
 
To install any node package we have to first initialize our project by running npm init -y which creates a package.json file that stores our project’s information

Nodemon Package

  • One famous package is Nodemon which helps to keep our file running whenever we make some changes. It is only needed in development so we install it with that flag
    • npm install --save-dev nodemon
  • Now we need to make changes to our package.json file
    • notion image
  • Now to run: npm start

Practice Set

  1. Create a new directory and initialize with npm init -y
  1. Then install parcel as a development dependency using npm install --save-dev parcel
  1. Now create a new file index.html and style.scss and insert some code in it
  1. Create entry for parcel inside the package.json file
    1. "start": "parcel index.html"
  1. Now parcel will serve this html file and will also transpile the scss back to css

🤖 moose wala