NPM Tutorial for Beginners - 6 - Installing Local Packages (English)

Опубликовано: 30 Март 2026
на канале: Future Dimensions 360
293
3

📫 Business - [email protected]

To install npm packages for your Node.js project, you can use the npm install command followed by the package name. Here's how you do it:

Installing a Package:
To install a package locally (meaning it's installed in your project's node_modules directory), run the following command in your project's root directory:

sh
Copy code
npm install package-name
Replace package-name with the name of the npm package you want to install. For example, to install the Express framework:

sh
Copy code
npm install express
Installing a Package and Saving it as Dependency:
By default, npm installs packages as dependencies and adds them to the dependencies section of your package.json file. This ensures that your project can use these packages consistently across different environments.

sh
Copy code
npm install package-name --save
The --save flag tells npm to save the package as a dependency in your package.json. For example:

sh
Copy code
npm install express --save
Installing a Package as a DevDependency:
DevDependencies are packages that are only needed during development, such as testing frameworks, build tools, etc. To install a package as a devDependency and add it to the devDependencies section of your package.json, use the --save-dev flag:

sh
Copy code
npm install package-name --save-dev
For example, to install Nodemon as a devDependency:

sh
Copy code
npm install nodemon --save-dev
Installing a Global Package:
Some npm packages are designed to be used globally, meaning they are installed once on your system and can be accessed from any directory. To install a package globally, use the -g flag:

sh
Copy code
npm install -g package-name
For example, to install the TypeScript compiler globally:

sh
Copy code
npm install -g typescript
After running these commands, npm will download and install the specified packages and their dependencies. The installed packages will be available for use in your Node.js project, and npm will update your package.json file accordingly if you used the --save or --save-dev flags.

#nodejs #javascript #coding #node #backend #nodejstutorial #nodejsdevelopment #tutorial #tutorials #programming #nodeprogramming

0:00 Introduction
0:53 Installing a Package
2:09 Installing a Dependency For Development