NPM

kartik goyal
2 min readJul 9, 2023
NPM

Npm created by github, it is very fast, very useful and it has no full form.

Problems to solve (in context of react)
cdn links very useful but are 3rd party links which creates unnecessary dependency on 3rd party service. Also handling version becomes problematic, and it is heavy for the application as it need to fetch the data from 3rd party service.

Npm solve above problem and provides many other functionality.
Npm have very useful commands and options few given below:
npm init — to initialize a new application
npm init -y — to automatically initiate pre configured project
npm i or npm install — to install packages from npm
npm i -D <package-name> — to intall packages for development aka dev dependencies. (Bundlers remove those packages from production and optimize our app) (optimise or optimize are both have same meaning and pronunciation is similar)
npm i <package-name> — install package for production
npm contains scripts for ex: “npm start” which are defined inside under script key we can utilize or create our own scripts inside package.json.
transitive dependency — dependent packages which are installed because of some packages install
Npm has a alternative yarn
Npm install following files package.json, package-lock.json, and node_module(folder)
package.json and package-lock.json — these files to maintain our application.
package files contains information about packages and contains many other commands.
The information about packages are stored in the package.json file (Do not add it in gitignore.) is its version number, and dependency. version number of a package have 3 signs with it — tilde(~), caret(^) and No sign()
No sign — shows exact version
tidle(~)(major) and caret(^)(minor) — learn more about this signs
package-lock.json — lock the package and its transitive dependency such as their exact version to be used in application and contain a hash for integrity (?). Do not add it in gitignore.
node modules is a folder which install the complete packages code and its dependencies to be used in the application which helps to get all functions from our own server which results in optimisation of our app as files are getting read from our own repo.

--

--