An warware: sigar rubutu na rage darajar

Nau'in cuta ya kasance fasaha mai mahimmanci a ci gaban yanar gizo na zamani saboda tanadar sa don duba nau'in a cikin Javascript, sauƙaƙe ingantaccen goyan bayan edita, bincika a tsaye, da kuma lalata mai ƙarfi a cikin ci gaban baya da gaba. Koyaya, masu haɓakawa galibi suna fuskantar ƙalubale lokacin da suke da su saukar da Typescript iri, musamman saboda wasu abubuwan dogaro na aikin na iya buƙatar ƙaramin sigar Typescript don ingantaccen aiki.

A wasu lokuta, aikin da aka rubuta a ƙaramin nau'in Typescript na iya yin aiki yadda ya kamata a ƙarƙashin sabon sigar da aka inganta don haka yana buƙatar rage darajar. A cikin wannan labarin, za mu shiga cikin tsari don rage darajar nau'in Rubutun ku cikin aminci.

The Magani

Don rage darajar nau'in Typescript, dole ne ku tabbatar kuna da muhallin da ke goyan bayan ku npm (Mai sarrafa fakitin Node) kamar yadda shine kayan aikin mu na rage darajar farko. Tsarin rage darajar ya ƙunshi cire nau'in Typescript na yanzu sannan kuma shigar da sigar da kuke so.

Fara da cire nau'in Typescript na yanzu ta amfani da umarnin npm:

npm uninstall -g typescript

Sannan, shigar da nau'in Typescript da kuke so ta amfani da umarnin npm tare da suffix @version:

npm install -g typescript@{version}

Ka tuna don maye gurbin "{version}" da nau'in Rubutun da kake so.

Cikakken Bayanin Code

Bari mu zurfafa zurfafa cikin kowane umarnin layin umarni da aka yi amfani da shi wajen rage darajar don ƙarin fahimtar ayyukansu.

Umurnin `npm uninstall -g typescript` yana ba da umarnin npm don cire fakitin "nau'in rubutu" na duniya. Anan, tutar `-g` ta fayyace cewa aikin yakamata ya shafi kunshin Nau'in Rubutun da aka shigar a duniya. Idan kuna son cire fakitin gida kawai (a cikin kundin adireshi na yanzu), zaku iya yin hakan ta hanyar tsallake tutar `-g`.

npm uninstall typescript

Umurni na gaba, `npm install -g typescript@{version}`, yana ba da umarni zuwa npm don shigar da takamaiman sigar Typescript. Tutar `-g` ta sake fayyace cewa tsarin yakamata ya kasance cikin mahallin duniya.

Yi aiki tare da ɗakunan karatu na Rubutun Daban-daban

A madadin, yanayi na iya tasowa inda kuke buƙatar kula da nau'ikan Rubutun Rubutun don ayyuka daban-daban. A irin waɗannan lokuta, kayan aiki kamar nvm (Mai sarrafa Node) ya zo da hannu. Tare da NVM, zaku iya kula da nodes daban, kowannensu tare da nau'in nau'in sa, yadda ya kamata nisantar rikice-rikicen sadarwa.

Hakanan, wani kayan aiki mai amfani shine `npm shrinkwrap` wanda ke ba ku damar kulle nau'ikan fakitin da aka shigar da zuriyarsu. Wannan yana tabbatar da cewa kuna amfani da nau'ikan fakiti iri ɗaya a kan dandamali daban-daban, kuma babu haɓakawa ta atomatik da ke faruwa.

Ka tuna, yadda yake sarrafa nau'ikan nau'ikan ku na yau da kullun yana taimakawa kula da karfin gwiwa kuma yana warware yiwuwar rikice-rikice, tabbatar da ingantattun ayyukan ku. Tabbatar cewa koyaushe kuna tabbatar da nau'in Rubutun ku ta amfani da umarnin `tsc -v` bayan kowane shigarwa ko cirewa.

tsc -v
Shafi posts:

Leave a Comment