About
package Dependency in Node.
Dependency are declared/added in package.json:
- with a package manager
- or manually
Type of dependency relationship
- Javascript Package - Dependencies - dependency in the code used to build the dependency graph.
- Javascript Package - Dev Dependency - build and test dependency that are not needed in the dependency graph (bundler, test harnesses or transpilers)
- What are Peer Dependencies? - A dependency that will be provided and is not needed in the bundle.
- Javascript Package - bundled Dependencies: an array of package names that will be bundled when publishing the package.
- optionalDependencies: build dependency failures do not cause installation to fail
Management
Installation of all dependencies
It will get the dependency from the package.json file
Installation of all dependency of a cloned project.
- for dev
git clone url
yarn install
# or
npm install
- for a continous integration. npm ci. Example: doc publishing
npm ci
Add a dependency to your project
See:
Exclude
To not include a dependency, you need to declare it as peerDependency