Install the package with npm install / yarn add

Premise

Reference: Npm and yarn command quick reference table

What is the global environment?

System common directory, node global environment Used when installing tools and commands used in the entire system

What is a local environment?

The environment in the application (project) that I made For the added package, describe "Which package to install" in package.json in the application (project). Used when installing packages used for each application


Install in global environment

The package is installed in the global environment of node ** -g option means global environment ** ** install can be omitted with i ** npm

npm install -g Package name

//The following is also OK

npm i -g Package name

yarn

yarn global add package name

Install to local environment

Add --save to install to local environment Once installed, it will be added to dependencies in the package.json file npm

npm install --save package name

yarn

yarn add package name

Install the development package in your local environment

Add --save-dev when installing Once installed, it will be added to devDependencies in the package.json file ** --save-dev can be omitted with -D ** npm

npm install --save-dev package name

//The following is also OK

npm i -D Package name

yarn

yarn add --dev package name

Tips

$ git pull origin master

//If you are developing on npm
$ npm install

//If developing with yarn
$ yarn install

Recommended Posts

Install the package with npm install / yarn add
Clogged with Express npm install
About the package
I updated Node.js with nodebrew and scripted the routine to re-install npm install -g
Refusing to install package with name "webpack" under a package
"This is the wrong package! Please install eslint-plugin-jsx-a11y" error
Install java with Homebrew
About npm install --save
Install Ruby 3.0.0 with asdf
Install Gradle with ubuntu16.04
Install Composer with Docker
Add a local Swift Package to your project with Swift PM