← Back to Node.js Course | Chapter 1: Introduction | Lesson 7 of 7

npm के Basics

npm Node का package manager है: यह दूसरे लोगों का code download करता है और आपके project की dependencies track करता है।

In this page:

  1. npm Basics
Syntax
javascript
npm init
npm install package_name
npm run script_name

npm Basics

npm init आपके project describe करने वाला एक package.json बनाता है। npm install <name> node_modules में एक package download करता है और इसे package.json में record करता है। npm run <script> scripts section में defined commands चलाता है।

Note: package.json और package-lock.json commit करें, कभी node_modules नहीं।

उदाहरण: npm basics

bash
$ npm init -y
$ npm install lodash
added 1 package in 2s
$ npm run
Scripts available in demo via `npm run-script`:
  start
    node index.js

⚠️ Run this in your own terminal or Node.js environment.

Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. node_modules को git में commit करना
  2. package-lock.json हाथ से edit करना
  3. जब एक local package safer हो तब global packages install करना
चैप्टर सारांश
  • npm init package.json बनाता है
  • npm install dependencies add करता है
  • npm run scripts चलाता है
  • node_modules commit न करें
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.