Sobes.tech
Junior — Middle

Kādi galvenie komandi tiek izmantojami, strādājot ar NPM pakotņu pārvaldnieku?

sobes.tech AI

Atbilde no AI

Galvenās NPM pakotņu pārvaldības komandas:

  • npm init — sāk jaunu projektu, izveidojot package.json failu.
  • npm install <package> vai npm i <package> — instalē pakotni un pievieno to atkarībām.
  • npm uninstall <package> — noņem pakotni no projekta.
  • npm update — atjaunina instalētās pakotnes uz jaunākajām versijām.
  • npm run <script> — izpilda lietotāja definētus skriptus, kas ir package.json.
  • npm list — parāda instalēto pakotņu sarakstu.
  • npm publish — publicē pakotni NPM reģistrā.
  • npm cache clean — notīra NPM kešatmiņu.

Piemērs, kā instalēt un palaist skriptu:

npm install express
npm run start

Šīs komandas ļauj pārvaldīt atkarības un automatizēt uzdevumus Node.js projektos.