Languages
[Edit]
EN

Node.js - install npm package locally

3 points
Created by:
Kenya-Spears
800

In this article, we would like to show you how toĀ install npm package locallyĀ inĀ Node.js.

As a localĀ installation, we understand the packages are installed in the current project directory only.

Quick solution:

npm install package-name

or shorter:

npm i package-name

Notes:

  • that approach is useful when the project uses specific packages versions (it is most common way to install packages in a project),
  • go to last section to see how to install packages that are used only in developlemnt.

Ā 

Installation variants

In this section, we present 2 installation variants: normal andĀ development dependencyĀ installation.

1.Ā  As normal dependency

Local installation in the current directory:

npm install package-name

# or:

npm install package-name-1 package-name-2 package-name-N

Before npm 5 we needed to use one of the variants:

npm install --save package-name
npm install --save package-name-1 package-name-2 package-name-N

npm install -S package-name
npm install -S package-name-1 package-name-2 package-name-N

npm i -S package-name
npm i -S package-name-1 package-name-2 package-name-N

2. As development dependency (devDependencies)

DevelopmentĀ dependenciesĀ areĀ not built into the production package - they are needed only for development,
e.g. nodemon, all @types/..., eslint, jest, typescript, etc.

npm install -D package-name

# or:

npm install -D package-name-1 package-name-2 package-name-N

or:

npm install --save-dev package-name

# or:

npm install --save-dev package-name-1 package-name-2 package-name-N

Alternative titles

  1. Node.js - install npm package as development dependency
  2. Node.js - install npm package as dev dependency
  3. Node.js - install npm package as devDependencies
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
šŸš€
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

ā¤ļøšŸ’» šŸ™‚

Join