杩樺湪鐢╪vm鍋歯ode绠$悊宸ュ叿锛熷揩鏉ヨ瘯璇昖olta鍚э紒
涓轰粈涔堜細鐢╒olta鍛紵 鍥犱负杩欐鏃堕棿鐢佃剳涓婄殑yarn鍑轰簡闂锛?strong>yarn install涔嬪悗灏辨姤閿?code>There appears to be trouble with your network connection. Retrying...锛屾湡闂存壘浜嗗緢澶氭柟娉曢兘娌℃湁瑙e喅锛屼絾鏄粖澶╃敤Volta瀹夎浜唝arn涔嬪悗灞呯劧濂囪抗鑸殑鍙互涓嬭浇浜嗭紝閫熷害杩樼壒鍒揩銆傝櫧鐒跺彲浠ヤ簡锛屼絾渚濈劧涓嶇煡閬撲粈涔堝師鍥犲鑷寸殑銆備笉杩囧張鍙互鐢▂arn浜嗭紝寮€蹇凁煒剘~
馃イ浠€涔堟槸Volta
鏍囬璇?Node.js 鐗堟湰鎺у埗锛屼絾浣犱篃鍙互鍋?npm/yarn 鐗堟湰鎺у埗銆傚湪瀹樻柟缃戠珯涓婏紝瀹冭浠嬬粛涓衡€滄棤蹇ф棤铏戠殑 JavaScript 宸ュ叿绠$悊鍣ㄢ€濄€傚綋鎴戞妸椤圭洰鐨?Node.js 鐨勭増鏈帶鍒剁粺涓€鍒?Volta 鐨勬椂鍊欙紝DX 涓婂幓浜嗗緢澶氾紝鎴戞劅鍙楀埌浜?Volta 鐨勫ソ澶勩€?/p>
鐩墠娌℃湁璇︾粏瑙i噴鐨勪腑鏂囪祫婧愶紝鎵€浠ユ垜闃呰浜嗗畼鏂规枃妗e苟閰屾儏灏嗗叾缈昏瘧鎴愪腑鏂囥€? 甯屾湜鏈夊ぇ浣彲浠ユ棤鐥涢槄璇诲苟浠嬬粛Volta銆?/p>
馃イVolta姒傝堪
鎴戜滑鏉ョ湅鐪嬪畼缃戜粙缁嶇殑涓変釜鍔熻兘銆?/p>
Get Started 鈫?/p>
鈿?Fast锝?蹇?/h5>
Install and run any JS tool quickly and seamlessly! Volta is built in Rust and ships as a snappy static binary.
蹇€熸棤缂濆湴瀹夎鍜岃繍琛屼换浣?JS 宸ュ叿锛乂olta 鍐呯疆浜?Rust 骞朵綔涓轰竴涓椿娉肩殑闈欐€佷簩杩涘埗鏂囦欢鎻愪緵銆?/p>
Volta 鏄敱 Rust 鍒朵綔鐨勶紝鍥犳瀹冩瘮鍏朵粬鐗堟湰鎺у埗宸ュ叿杩愯寰楁洿蹇€?*** 蹇偣寰堝ソ銆?**
鈿?Reliable锝?绋冲浐锝滃彲闈?/h5>
Ensure everyone in your project has the same tools鈥攚ithout interfering with their workflow.
纭繚椤圭洰涓殑姣忎釜浜洪兘鎷ユ湁鐩稿悓鐨勫伐鍏凤紝鑰屼笉浼氬共鎵颁粬浠殑宸ヤ綔娴佺▼ 銆?/p>
杩欐槸鎴戣寰楁渶鍙楃泭鐨勫湴鏂广€? volta pin
鎮ㄥ彲浠ヤ娇鐢ㄨ鍛戒护杞绘澗瀵归綈椤圭洰鎴愬憳鐨?Node.js 鍜?npm 鐗堟湰銆?/p>
鎴戝皢鍦ㄦ枃绔犲悗闈㈣缁嗚В閲婂浣曚娇鐢ㄥ畠锛屾墍浠ユ垜鍏堟斁鐫€瀹冦€?/p>
鈿?Universal锝?涓囪兘
No matter the package manager, Node runtime, or OS, one command is all you need: volta install
.
鏃犺鏄寘绠$悊鍣ㄣ€丯ode 杩愯鏃惰繕鏄搷浣滅郴缁燂紝鎮ㄥ彧闇€瑕佷竴涓懡浠わ細
volta install
.
Windows/Mac/Linux銆傞€傜敤浜庝换浣曟搷浣滅郴缁熴€?/p>
闄ら潪姣忎釜浜洪兘鍦ㄤ娇鐢?Volta锛屽惁鍒欏畠鏃犳硶宸ヤ綔锛屽洜姝ゅ畠鍙互鍦ㄤ换浣曟搷浣滅郴缁熶笂杩愯寰堥噸瑕併€?/p>
馃敂鐗圭偣
璁╂垜浠揩閫熸祻瑙堜竴涓嬭繖浜涘姛鑳姐€?/p>
閫熷害鈿★笍
閫愪釜椤圭洰鐨勬棤缂濈増鏈垏鎹?/p>
璺ㄥ钩鍙版敮鎸侊紝鍖呮嫭 Windows 鍜屾墍鏈?Unix shell
鏀寔澶氫釜鍖呯鐞嗗櫒
宸ュ叿瀹夎绋冲畾锛堟瘡娆¤妭鐐瑰崌绾у悗鏃犻渶閲嶆柊瀹夎锛?/p>
鐢ㄤ簬鐗瑰畾浜庣珯鐐圭殑鑷畾涔夌殑鍙墿灞曟€ф寕閽?/p>
鉂o笍涓轰粈涔堣浣跨敤 Volta锛燂綔 涓轰粈涔堥€夋嫨Volta锛?/h2>
浣跨敤 Volta锛屼竴鏃︽偍閫夋嫨浜?Node 寮曟搸锛屾偍灏变笉蹇呮媴蹇冨畠銆傚垏鎹㈤」鐩笉闇€瑕佹偍鎵嬪姩鍒囨崲鐗堟湰銆傛偍鍙互鍦ㄥ伐鍏烽摼涓畨瑁?npm 杞欢鍖呬簩杩涘埗鏂囦欢锛岃€屾棤闇€瀹氭湡閲嶆柊瀹夎瀹冧滑鎴栨壘鍑哄畠浠仠姝㈠伐浣滅殑鍘熷洜銆?/p>
蹇€熻缃拰鍒囨崲 Node 寮曟搸
鎮ㄥ彲浠ヨ幏鍙栧拰浣跨敤鐗瑰畾鐗堟湰鐨勮妭鐐广€?/p>
浣跨敤 Volta锛屼竴鏃︽偍閫夋嫨浜?Node 寮曟搸锛屾偍灏变笉蹇呮媴蹇冨畠銆傚垏鎹㈤」鐩笉闇€瑕佹偍鎵嬪姩鍒囨崲鐗堟湰銆傛偍鍙互鍦ㄥ伐鍏烽摼涓畨瑁?npm 杞欢鍖呬簩杩涘埗鏂囦欢锛岃€屾棤闇€瀹氭湡閲嶆柊瀹夎瀹冧滑鎴栨壘鍑哄畠浠仠姝㈠伐浣滅殑鍘熷洜銆?/p>
鎮ㄥ彲浠ヨ幏鍙栧拰浣跨敤鐗瑰畾鐗堟湰鐨勮妭鐐广€?/p>
缁堢
$ volta install node@14
鎮ㄤ細绔嬪嵆娉ㄦ剰鍒拌宸ュ叿鐨勫搷搴旇兘鍔涖€傛偍鐨勫紑鍙戞椂闂村緢瀹濊吹锛丣avaScript 寮€鍙戜汉鍛樺簲璇ュ緱鍒颁竴涓揩閫熺殑宸ュ叿銆傪煓?/p>
褰撶劧鎴戣寰楀畨瑁呭緢蹇€?/p>
鍗忎綔鑰呯殑鍙鍒剁幆澧?/h3>
Volta 鍏佽鎮ㄤ娇鐢ㄥ崟涓懡浠ら€夋嫨椤圭洰鐨勮妭鐐瑰紩鎿庡拰鍖呯鐞嗗櫒銆?/p>
~~璺緞/鍒?浣犵殑/椤圭洰~~
$ volta pin node@12
Volta 灏?Node 寮曟搸鐨勭‘鍒囩増鏈瓨鍌ㄥ湪 package.json 涓紝鍥犳鎮ㄥ彲浠ュ皢鎮ㄧ殑閫夋嫨鎻愪氦缁?git銆備粠閭f椂璧凤紝姣忔鎮ㄥ湪椤圭洰鐩綍涓繍琛?Node 鏃讹紝Volta 閮戒細鑷姩鍒囨崲鍒颁笌鎮ㄩ€夋嫨鐩稿悓鐗堟湰鐨?Node 銆傚悓鏍凤紝鎮ㄧ殑鍚堜綔鑰呬篃鍙互閫氳繃鍦ㄤ粬浠悇鑷殑寮€鍙戞満鍣ㄤ笂瀹夎 Volta 鏉ュ仛鍚屾牱鐨勪簨鎯呫€?/p>
Volta 鍏佽鎮ㄤ娇鐢ㄥ崟涓懡浠ら€夋嫨椤圭洰鐨勮妭鐐瑰紩鎿庡拰鍖呯鐞嗗櫒銆?/p>
~~璺緞/鍒?浣犵殑/椤圭洰~~
$ volta pin node@12
Volta 灏?Node 寮曟搸鐨勭‘鍒囩増鏈瓨鍌ㄥ湪 package.json 涓紝鍥犳鎮ㄥ彲浠ュ皢鎮ㄧ殑閫夋嫨鎻愪氦缁?git銆備粠閭f椂璧凤紝姣忔鎮ㄥ湪椤圭洰鐩綍涓繍琛?Node 鏃讹紝Volta 閮戒細鑷姩鍒囨崲鍒颁笌鎮ㄩ€夋嫨鐩稿悓鐗堟湰鐨?Node 銆傚悓鏍凤紝鎮ㄧ殑鍚堜綔鑰呬篃鍙互閫氳繃鍦ㄤ粬浠悇鑷殑寮€鍙戞満鍣ㄤ笂瀹夎 Volta 鏉ュ仛鍚屾牱鐨勪簨鎯呫€?/p>
杩欏氨鏄疺olta鐨勫叏閮ㄦ剰涔夋墍鍦ㄣ€傝繖鏄瘡涓汉閮藉湪浣跨敤Volta鐨勬潯浠讹紝浣嗘槸鍒涘缓鐜鐨勪汉鍙互volta pin
閫氳繃鍛戒护淇鐗堟湰锛屽叾浠栨垚鍛樺彲浠ヤ笉鍋囨€濈储鍦版墽琛屽畠npm install
銆? 鑳界渷鍘绘鏌ョ増鏈殑楹荤儲銆?/p>
馃槒閲嶆柊瀹夎锛?/h3>
Volta 鍏佽鎮ㄥ皢鍠滄鐨勮蒋浠跺寘浜岃繘鍒舵枃浠跺畨瑁呬负鍛戒护琛屽伐鍏凤紝鑰屼笉蹇呮媴蹇冧細鐮村潖鎮ㄧ殑寮€鍙戦」鐩€傛洿濂界殑鏄紝杩欎簺宸ュ叿鍦ㄥ畨瑁呮湡闂村浐瀹氬埌鐗瑰畾鐨?Node 寮曟搸锛岄櫎闈炴偍鏄庣‘鎸囩ず瀹冧滑锛屽惁鍒欎笉浼氭洿鏀广€?/p>
$ npm install -g surge
$ surge -h
Volta 鍏佽鎮ㄥ皢鍠滄鐨勮蒋浠跺寘浜岃繘鍒舵枃浠跺畨瑁呬负鍛戒护琛屽伐鍏凤紝鑰屼笉蹇呮媴蹇冧細鐮村潖鎮ㄧ殑寮€鍙戦」鐩€傛洿濂界殑鏄紝杩欎簺宸ュ叿鍦ㄥ畨瑁呮湡闂村浐瀹氬埌鐗瑰畾鐨?Node 寮曟搸锛岄櫎闈炴偍鏄庣‘鎸囩ず瀹冧滑锛屽惁鍒欎笉浼氭洿鏀广€?/p>
$ npm install -g surge
$ surge -h
鍗充娇浣跨敤姝ゅ叏灞€瀹夎锛屼篃浼氫负姣忎釜椤圭洰璁颁綇鐗堟湰锛屽洜姝ゆ偍涓嶅繀鎷呭績鐗堟湰銆?/p>
馃洜锔忓畨瑁?Volta | 鍏ラ棬
鐜板湪璁╂垜浠畨瑁?Volta銆?/p>
瀹夎鍓嶆渶濂芥妸褰撳墠浣跨敤鐨凬ode鐗堟湰鎺у埗宸ュ叿鍘绘帀锛屼絾涔熷苟闈炲繀椤荤殑銆?/p>
宸ュ叿鐨勫垹闄ら儴鍒嗭紙nodebrew, NVM, nodist, ...锛夌殑妯″紡澶浜嗭紝鎵€浠ユ垜灏辩渷鐣ュ垹闄ゆ柟娉曚簡銆傝鏍规嵁鑷繁鐨勭幆澧冩鏌ワ紒
濡傛灉鎸夌収浜唍odebrew锛屽彲浠ラ€氳繃鍙傝€冭繖绡囨枃绔犲皢鍏跺垹闄ゃ€?/p>
瀹夎Volta
鎸夌収瀹樻柟鍏ラ棬瀹夎銆?/p>
濡傛灉鎿嶄綔绯荤粺鏄?Mac / Linux锛堝寘鎷?WSL锛夛紝鎮ㄥ彲浠ヤ娇鐢ㄤ互涓嬪懡浠よ交鏉惧畨瑁呭畠銆?/p>
$ curl https://get.volta.sh | bash
鍛戒护鏄?code>| bash锛屼絾鍗充娇鏄偅浜涗娇鐢?zsh /fish 鐨勪汉涔熷彲浠ユ鏃犻棶棰樺湴瀹夎瀹冦€傝鎴戜滑鐓у師鏍峰仛鍚э紒
鎴戝緢鎰熸縺閫氳璇佷細鑷姩閫氳繃銆?/p>
瀵逛簬 Windows锛屽彲浠ヤ娇鐢?Windows 瀹夎绋嬪簭锛屼竴璺痭ext鍗冲彲
鈿狅笍瀵逛簬 Windows锛屼娇鐢?Volta 浼间箮闇€瑕佷竴浜涜缃紝鍥犳璇锋寜鐓у畼缃戠殑璇存槑杩涜璁剧疆銆傦紝 ~/.zshrc 閲嶆柊鍚姩缁堢涓€娆?code>volta锛屾鏌ユ槸鍚﹀彲浠ヤ娇鐢ㄨ鍛戒护銆?/p>
Volta 鐨勫伐浣滄槸 Volta 宸ュ叿閾剧鐞嗙殑宸ュ叿鐢?code>volta install涓や釜 鍦ㄥ伐鍏烽摼涓畨瑁呭伐鍏锋椂锛屽畨瑁呯殑鐗堟湰鏄宸ュ叿鐨?em>榛樿鐗堟湰銆傞櫎闈炴偍鍦ㄤ竴涓」鐩洰褰曚腑宸ヤ綔锛屽叾涓偍鏈変竴涓浐瀹氱増鏈殑 Node 浠ヤ娇鐢ㄤ笉鍚岀殑鐗堟湰锛屽惁鍒欏畠榛樿涓?Volta 浣跨敤鐨勭増鏈€?/p>
渚嬪锛屾偍鍙互閫氳繃瀹夎鐗瑰畾鐗堟湰鏉ラ€夋嫨 Node 鐨勯粯璁ょ増鏈€?/p>
濡傛灉鎮ㄦ病鏈夋寚瀹氱‘鍒囩殑鐗堟湰锛孷olta 浼氶€夋嫨涓庢偍鐨勮姹傜浉鍖归厤鐨勯€傚綋鐗堟湰銆?/p>
褰撴偍杩愯浠讳綍杩欎簺鍛戒护鏃讹紝鐢?Volta 鍦?PATH 鐜锛堟垨 Windows 涓婄殑 Path锛変腑鎻愪緵鐨勮妭鐐瑰彲鎵ц鏂囦欢榛樿鑷姩杩愯鎵€閫夌増鏈殑鑺傜偣銆?/p>
鍚屾牱锛屾偍鍙互浣跨敤 灏哣olta淇濆瓨鍒癭package. JSON: 杩欐牱锛屼娇鐢?Volta 杩涜椤圭洰寮€鍙戠殑姣忎釜浜洪兘灏嗚嚜鍔ㄨ幏寰椾笌json璁剧疆鐨勭浉鍚岀増鏈€?/p>
node鍜屽寘绠$悊鍣ㄥ彲鎵ц鏂囦欢涓嶆槸宸ュ叿閾句腑鍞竴鐨勬櫤鑳藉伐鍏枫€傚伐鍏烽摼涓殑鍖呬簩杩涘埗鏂囦欢涔熷彲浠ヨ瘑鍒綋鍓嶇洰褰曞苟灏婇噸褰撳墠椤圭洰缁撴瀯銆?/p>
渚嬪锛屽畨瑁?Typescript 鍖呬細灏嗙紪璇戝櫒鍙墽琛屾枃浠?( 鏍规嵁鎮ㄥ弬涓庣殑椤圭洰锛屾鍙墽琛屾枃浠跺皢鍒囨崲鍒版偍椤圭洰涓€夋嫨鐨?TypeScript 鐗堟湰銆?/p>
濡傛偍鎵€瑙侊紝涓嶄粎 Node 鍜?npm / Yarn 绛夊寘绠$悊鍣紝鑰屼笖閫氳繃瀹冧滑瀹夎鐨勫寘浜岃繘鍒舵枃浠堕兘鍙楀埌 Volta 鐨勭洃鎺с€傚洜姝わ紝瀹冧細鑷姩鍒囨崲姣忎釜椤圭洰鐨勭増鏈€?/p>
Volta 鐨勫伐鍏烽摼浼氳窡韪偍鐨勪綅缃€傚洜姝わ紝鎮ㄤ娇鐢ㄧ殑宸ュ叿灏嗗缁堜紭鍏堣€冭檻鎮ㄦ鍦ㄥ鐞嗙殑椤圭洰鐨勮缃€傝繖鎰忓懗鐫€鎮ㄥ湪鍒囨崲椤圭洰鏃朵笉蹇呮媴蹇冩洿鏀瑰凡瀹夎杞欢鐨勭姸鎬併€?/p>
姝ゅ锛屾瘡娆¤繍琛屽伐鍏锋椂锛孷olta 閮戒細瑕嗙洊璺熻釜锛屼娇 npm 鎴?Yarn 鑴氭湰姘歌繙涓嶄細鐭ラ亾宸ュ叿閾剧殑鍐呭銆?/p>
缁撳悎杩欎袱涓壒鎬э紝Volta 瑙e喅浜嗗叏灞€灏佽鐨勯棶棰樸€傛崲鍙ヨ瘽璇达紝Volta 鎻愪緵浜嗗叏灞€鍖呭畨瑁呯殑渚垮埄锛屼絾娌℃湁鍗遍櫓銆?/p>
渚嬪锛?code>npm i -g typescript鎮ㄥ彲浠ュ畨鍏ㄥ湴瀹夎 TypeScript锛?code>tsc骞朵韩鍙楃洿鎺ヤ粠鎺у埗鍙拌皟鐢ㄥ畠鐨勪究鍒┿€?/p>
鏈€鍚庯紝鎴戞兂浠嬬粛涓€浜涘父鐢ㄧ殑鍛戒护銆?/p>
濡備綍浣跨敤 涓婇潰璇存槑浜嗗畨瑁呮椂鎸囧畾鐗堟湰鐨勬柟娉曪紝浣嗘€荤粨濡備笅銆?/p>
姝ゅ懡浠ゅ彧鑳界敤浜庤妭鐐瑰拰鍖呯鐞嗗櫒锛坣pm / Yarn锛夈€?/p>
浣跨敤鏂规硶鏄?code>volta pin [FLAGS] <tool[@version]>銆?/p>
鍦ㄩ」鐩洰褰曚腑鎵ц涓婅堪 閫氳繃涓庢偍鐨勫洟闃熷叡浜 渚嬪锛屽亣璁炬偍鍦?code>package.json涓€涓」鐩腑杩愯浜嗕笂杩拌缃€傚鏋?npm 鐨勭増鏈紦瀛樺湪 鏈湴鏈哄櫒涓婏紝灏嗘樉绀恒€?濡傛灉瀹冩病鏈夌紦瀛樺湪鏈湴鏈哄櫒涓婏紝瀹冨皢浠庡畨瑁呭紑濮嬶紝骞跺湪瀹夎瀹屾垚鏃舵樉绀恒€?code>npm -v 杩欐牱锛屽鏋滀綘鏈湴鏈夐偅涓増鏈紝瀹冧細鑷姩鍒囨崲鍒伴偅涓増鏈紝鍚﹀垯瀹冧細浠庣増鏈畨瑁呭紑濮嬨€?/p>
杩欏緢鏂逛究锛岃€屼笖 濡備綍浣跨敤 鍐欎簡杩欎箞闀跨殑涓€鍙ヨ瘽锛屽笇鏈涘ぇ瀹惰兘鏄庣櫧Volta鐨勯瓍鍔涖€?/p>
鎴戣涓鸿繖瀵逛簬涓昏寮€鍙?JavaScript 鐨勪汉鏉ヨ鏄渶濂界殑瑙e喅鏂规銆?/p>
鎴戜滑鐩镐俊鎮ㄤ娇鐢?Volta 鐨勪汉瓒婂锛屾偍灏辫秺鑳戒韩鍙楀埌瀹冪殑濂藉锛屾墍浠ヨ鑰冭檻灏嗗畠浠嬬粛缁欐偍鐨勫紑鍙戝洟闃熴€?/p>
馃檹鎰熻阿鎮ㄩ槄璇诲埌鏈€鍚庛€傚啀瑙併€?/p>浣嗘槸鎴戞病鏈夎缃緷鏃у彲浠ヤ娇鐢?/del>锛屽彲浠ョ悊瑙d负寮€绠卞嵆鐢ㄣ€?/p>
纭宸插畨瑁?/h2>
.zshrc
鏌ョ湅shell閰嶇疆鏂囦欢濡傚甫鏈?code>cat鍛戒护鐨勬枃浠剁瓑锛屽鏋滃啓鍏ュ涓嬭矾寰勶紝灏監K浜嗐€?/p>
export VOLTA_HOME="$HOME/.volta"
export PATH="$VOLTA_HOME/bin:$PATH"
$ volta --version
鉁斾簡瑙?Volta
node
绠$悊JavaScript 鍛戒护琛屽伐鍏凤紝渚嬪浣滀负 JavaScript 鍖呯殑涓€閮ㄥ垎鎻愪緵鐨勫彲鎵ц鏂囦欢npm
銆?涓庡寘绠$悊鍣ㄤ竴鏍凤紝Volta 浼氭牴鎹偍褰撳墠鐨勭洰褰曡窡韪偍姝e湪澶勭悊鐨勯」鐩€俈olta 宸ュ叿閾句腑鐨勫伐鍏蜂細鑷姩妫€娴嬫偍鍦ㄤ娇鐢ㄧ壒瀹氱増鏈伐鍏风殑椤圭洰涓紝骞跺皢鎮ㄥ紩瀵煎埌鏈€閫傚悎鎮ㄧ殑宸ュ叿鐗堟湰銆?code>yarn绠$悊浣犵殑宸ュ叿閾?/h2>
volta uninstall
鍛戒护鎺у埗Node瀹夎
$ volta install node@14.15.5
$ volta install node@14
latest
鎮ㄤ篃鍙互瀹夎鏈€鏂扮増鏈€傛澶栵紝濡傛灉鎮ㄥ畬鍏ㄧ渷鐣ョ増鏈紝Volta 灏嗛€夋嫨骞跺畨瑁呮渶鏂扮殑 LTS 鐗堟湰銆?/p>
$ volta install node@latest
# Node@LTS
$ volta install node
volta install npm
鍜?code>volta install yarn鍒嗗埆閫夋嫨 npm 鍜?Yarn 鍖呯鐞嗗櫒鐨勭増鏈€傝繖浜涘伐鍏蜂娇鐢ㄦ墍閫夎妭鐐圭殑榛樿鐗堟湰杩愯銆?/p>
鑺傜偣寮曟搸鍥哄畾
volta pin
鎮ㄥ彲浠ヤ娇鐢ㄥ懡浠ゆ潵閫夋嫨椤圭洰鐨?Node 寮曟搸鍜屽寘绠$悊鍣ㄧ殑鐗堟湰銆?/p>
$ volta pin node@14.17
$ volta pin npm@6.14
"volta": {
"node": "14.17.3",
"npm": "6.14.13"
}
浣跨敤椤圭洰宸ュ叿
tsc
) 娣诲姞鍒板伐鍏烽摼涓€?/p>
$ npm install --global typescript
cd /path/to/project-using-typescript-3.9.4
tsc --version # 3.9.4
cd /path/to/project-using-typescript-4.1.5
tsc --version # 4.1.5
瀹夊叏渚垮埄
馃挕Volta 鍛戒护
volta
鍛戒护琛屼簩杩涘埗鍙傝€冨涓嬨€傦紙鐐规鏌ョ湅瀹樻柟鍛戒护鍙傝€冿級
The JavaScript Launcher 鈿?
To install a tool in your toolchain, use `volta install`.
To pin your project's runtime or package manager, use `volta pin`.
USAGE:
volta [FLAGS] [SUBCOMMAND]
FLAGS:
--verbose
Enables verbose diagnostics
--quiet
Prevents unnecessary output
-v, --version
Prints the current version of Volta
-h, --help
Prints help information
SUBCOMMANDS:
fetch Fetches a tool to the local machine
install Installs a tool in your toolchain
uninstall Uninstalls a tool from your toolchain
pin Pins your project's runtime or package manager
list Displays the current toolchain
completions Generates Volta completions
which Locates the actual binary that will be called by Volta
setup Enables Volta for the current user/shell
help Prints this message or the help of the given subcommand(s)
Volta甯哥敤鍛戒护浠嬬粛
volta install
volta install
璁剧疆宸ュ叿鐨勯粯璁ょ増鏈€傚鏋滄湭缂撳瓨鏈湴鎸囧畾鐨勭増鏈紝璇蜂粠璇ュ伐鍏蜂腑鑾峰彇瀹冦€?/p>
volta install [FLAGS] <tool[@version]>
銆?/p>
# 瀹夎鎸囧畾鐗堟湰鐨刵ode
$ volta install node@14.17.3
# 瀹夎鐗瑰畾鐗堟湰涓殑绋冲畾鐨刵ode鐗堟湰
$ volta install node@14
# 瀹夎LTS鐗堟湰鐨刵ode
$ volta install node
# 瀹夎鏈€鏂扮増鏈殑node
$ volta install node@latest
volta pin
volta pin``package.json
璇ュ懡浠ゆ洿鏂伴」鐩枃浠朵互浣跨敤鎵€閫夌増鏈殑宸ュ叿銆?/p>
# node鐗堟湰鍥哄畾
$ volta pin node@14.17
# npm鐗堟湰鍥哄畾
$ volta pin npm@6.14
# or volta pin yarn@1.19
volta pin
鍛戒护鏃讹紝package.json
灏嗗啓鍏ヤ互涓嬭缃€?/p>
{
...,
+ "volta": {
+ "node": "14.17.3",
+ "npm": "6.14.13" //or "yarn": "1.19.2"
+ }
}
package.json
鍐呭锛屼緥濡傚湪 GitHub 涓婏紝姣忎釜浜洪兘鍙互浣跨敤鐩稿悓鐗堟湰鐨?Node 鎴?npm銆?/p>
6.14.13``6.14.13
6.14.13``6.14.13
npm install
鍗充娇浣犺繍琛屽畠鑰屼笉鐢ㄦ媴蹇冪増鏈紝鐗堟湰涔熶細鑷姩瀵归綈锛屾墍浠?code>package-lock.json涓嶄細鏈変换浣曞樊寮傘€傦紙npm 6绯诲拰7绯?code>package-lock.json鐨勫唴瀹瑰緢涓嶄竴鏍枫€傦級volta list
volta list
璇ュ懡浠ゆ鏌ュ苟鏄剧ず鍖呭惈宸插畨瑁?Node 杩愯鏃躲€佸寘绠$悊鍣ㄥ拰浜岃繘鍒舵枃浠剁殑鍖呫€?/p>
volta list [FLAGS] [OPTIONS] [tool]
銆?/p>
volta list
璇ュ懡浠ょ殑鐢ㄦ硶鎬荤粨濡備笅銆?/p>
# 浣跨敤鏂规硶
volta list [FLAGS] [OPTIONS] [tool]
# Flags
-c, --current # 鏄剧ず褰撳墠娲诲姩宸ュ叿
# 姝ゆ爣蹇椾负缂虹渷璁剧疆
-d, --default # 鏄剧ず榛樿宸ュ叿
--verbose # 鍚敤楂樼骇璇婃柇
--quiet # 闃叉涓嶅繀瑕佺殑鏄剧ず
-h, --help # 鏄剧ず甯姪淇℃伅
# OPTIONS
--format <format> # 鎸囧畾杈撳嚭鏍煎紡
# 鏈夋晥鍊间负`human`or`plain`
# 榛樿鍊间负`human`锛屽惁鍒欎负`plain`
# ARGS
<tool> # 鎸囧畾瑕佸垪鍑虹殑宸ュ叿锛坣ode锛宯pm锛寉arn鎴栧叾浠栦簩杩涘埗鏂囦欢锛?
# 鎸囧畾all浠ユ樉绀烘墍鏈夊唴瀹?
volta list
鎮ㄥ彲浠ユ煡鐪嬭椤圭洰涓娇鐢ㄧ殑宸ュ叿鐨勭増鏈€?/p>
volta list all
鐜板湪鎮ㄥ彲浠ョ湅鍒?Volta 绠$悊鐨勫伐鍏峰垪琛ㄣ€?/p>
馃挰姒傛嫭