An warware: ƙara sabon sigar zuwa kunshin json

An fahimta! Bari mu shiga cikin batun sabuntawa da ƙara sabon sigar zuwa package.json a cikin mahallin ci gaban JavaScript.

Package.json shine muhimmin sashi na kowane aikin Node.js ko JavaScript. Yana kiyaye metadata game da aikin kuma ya haɗa da bayanai game da dogaron aikin. Sau da yawa, a matsayin mai haɓakawa, ƙila ka buƙaci sabunta abubuwan dogaro na aikin zuwa sabbin sigar su saboda sabbin fasalulluka, sabunta tsaro, haɓaka aiki, ko gyaran kwaro. Saboda haka, sanin yadda ake ƙara sabon sigar zuwa package.json fasaha ce mai mahimmanci.

Ana ɗaukaka zuwa Sabon Sigar

Don sabunta fakitin, mataki na farko shine gano tsoffin fakitin. A cikin Node.js, umarnin don gano abubuwan da suka gabata shine
npm outdated

Bayan gudanar da wannan umarni, npm zai jera duk fakitin da suka tsufa, sigar su na yanzu a cikin aikinku, sigar da aka ƙayyade a cikin `package.json`, da sabuwar sigar da ake da ita.

Mataki na gaba shine sabunta waɗannan tsoffin fakitin. Kuna iya sabunta su daidaiku ta amfani da su
npm install [package-name]@latest --save
ko sabunta su duka tare da umarnin

npm update

Duba cikin Zurfin Npm

Npm ko Node Package Manager kayan aiki ne mai ƙarfi wanda ke ba masu haɓaka JavaScript damar rabawa da sarrafa kayayyaki ko fakiti. Manajan fakitin tsoho ne na Node.js kuma yana zuwa an riga an shigar dashi lokacin da kuka shigar da Node.js.

Npm yana sabunta fakiti bisa ga ma'anar fassara (SemVer). SemVer yana amfani da tsarin juzu'i na Major.Minor.Patch. Lokacin da npm ke sabunta fakiti, yana bin waɗannan dokoki:

  • Fitar da faci: sabunta npm a cikin kewayon da aka ƙayyade.
  • Ƙananan sakewa: npm sabuntawa zuwa ƙarami mafi girma.
  • Manyan sakewa: npm ba za ta ɗaukaka ba sai dai in an ƙayyade sigar a cikin kunshin.json.

Fahimtar kunshin.json

Fayil ɗin `package.json` yana riƙe da metadata game da aikin, gami da dogaron aikin da takamaiman nau'ikan su. Abubuwan dogara na iya lissafin duk fakitin da ake buƙata don aikin ku. Lokacin da wani mai haɓakawa ko tsarin turawa ya gudana `npm install`, npm yana duba `package.json` kuma yana zazzage duk fakitin da aka jera da abubuwan dogaronsu.

Kowane fakiti a cikin sashin "dogara" na fayil 'package.json' yana bin tsarin sigar, wanda npm ke fassara lokacin da ake gudanar da 'npm install'. Akwai manyan alamomi guda uku da ake amfani da su - kula (^), tilde (~), da tauraro (*). Waɗannan sun dace da manyan, ƙanana, da sabunta faci.

A ƙarshe, yana da mahimmanci don ci gaba da sabunta abubuwan dogaro na aikin ku. Sanin yadda ake ƙara sabon sigar zuwa package.json ƙwarewa ce mai mahimmanci ga mai haɓaka JavaScript don ci gaba da sabunta aikin tare da sabbin abubuwan tsaro da sabbin abubuwa.

Shafi posts:

Leave a Comment