npm add optional dependency 1

npm add optional dependency

npm install -O 
npm install --save-optional 

Here is what the above code is Doing:
1. npm install -g
– Installs the dependency globally.
– This is useful for installing command line tools.
– For example, if you want to install a tool called “grunt-cli” globally, you would run:
npm install -g grunt-cli
2. npm install –save
– Installs the dependency locally.
– This is useful for installing packages that you want to use in your application.
– For example, if you want to install a package called “lodash” locally, you would run:
npm install –save lodash
3. npm install –save-dev
– Installs the dependency locally as a development dependency.
– This is useful for installing packages that you want to use in your application for development purposes.
– For example, if you want to install a package called “grunt” locally as a development dependency, you would run:
npm install –save-dev grunt
4. npm install -O
– Installs the dependency locally as an optional dependency.
– This is useful for installing packages that you want to use in your application, but are not required.
– For example, if you want to install a package called “mocha” locally as an optional dependency, you would run:
npm install -O mocha
5. npm install –save-optional
– Installs the dependency locally as an optional dependency.
– This is useful for installing packages that you want to use in your application, but are not required.
– For example, if you want to install a package called “mocha” locally as an optional dependency, you would run:
npm install –save-optional mocha

Similar Posts