npm文檔what_is_npm

Q1:npm是什么烁峭?

npm是一個(gè)Javascript的包管理器。尋找鬓梅,分享,重用成百上千的開(kāi)發(fā)者創(chuàng)造的代碼。用更強(qiáng)力的方式組合它們活孩。

If you've been working with Javascript for awhile, you might have heard of npm: npm makes it easy for Javascript developers to share the code that they've created to solve particular problems, and for other developers to reuse that code in their own applications.

2

Once you're depending on this code from other developers, npm makes it really easy to check to see if they've made any updates to it, and to download those updates when they're made.

一旦你依賴其他開(kāi)發(fā)者的代碼乃沙,npm讓檢查它們的任何升級(jí)變得簡(jiǎn)單阳掐,并且在他們完成時(shí)下載這些升級(jí)汛闸。

These bits of reusable code are called packages, or sometimes modules. A package is just a directory with one or more files in it, that also has a file called "package.json" with some meta data about this package. A typical application, such as a website, will depend on dozens or hundreds of packages. These packages are often small. The general idea is that you create a small building block which solves one problem and solves it well. This makes it possible for you to compose larger, custom solutions out of these small, shared building blocks.

這些重用的代碼被稱為包钳恕,或者模塊厘肮。一個(gè)包只是一個(gè)包含一個(gè)或多個(gè)文件的目錄,里面還由一個(gè)包含一些元數(shù)據(jù)的叫”package.json“的文件睦番。一個(gè)典型的應(yīng)用类茂,比如一個(gè)網(wǎng)站,回依賴一打或者幾百個(gè)包托嚣。這些包通常都很小巩检。一個(gè)通常的想法,你創(chuàng)建一小塊解決一個(gè)問(wèn)題并且解決地很好的積木示启。這讓你通過(guò)這些小的被fen'xiang組合更大兢哭、定制的解決方案。

There's lots of benefits to this. It makes it possible for your team to draw on expertise outside of your organization by bringing in packages from people who have focused on particular problem areas. But even if you don't reuse code from people outside of your organization, using this kind of module based approach can actually help your team work together better, and can also make it possible to reuse code across projects.

這樣會(huì)由很多好處夫嗓。通過(guò)引入專注特定問(wèn)題領(lǐng)域的人開(kāi)發(fā)的包厦瓢,這讓你的團(tuán)隊(duì)靠近領(lǐng)域之外的專業(yè)知識(shí)稱為可能。但紀(jì)實(shí)你不會(huì)重用團(tuán)隊(duì)外的人的代碼啤月,使用這些基于方法的模塊會(huì)幫助你的團(tuán)隊(duì)更好地協(xié)作,也會(huì)使跨項(xiàng)目重用代碼車稱為可能劳跃。

You can find packages to help you build your application by browsing the npm website. When you're browsing the website, you'll find different kinds of packages. You'll find lots of node modules. npm started as the node package manager, so you'll find lots of modules which can be used on the server side. There are also lots of packages which add commands for you to use in the command line. And at this point you can find a number of packages which can be used in the browser, on the front end.

你可以通過(guò)瀏覽npm的網(wǎng)站谎仲,尋找包們,來(lái)幫助你創(chuàng)建應(yīng)用刨仑。當(dāng)你瀏覽網(wǎng)站時(shí)郑诺,你會(huì)找到不同類型的包。你會(huì)找到大量的node包杉武。npm始于node包管理器辙诞,因此,你會(huì)找到大量用于服務(wù)端的模塊轻抱。也存在很多為了通過(guò)命令行使用而增加命令的包飞涂。此刻,你會(huì)找到用于瀏覽器前端的包。

So now that you have an idea of what npm can do, let's talk about how it works. When people talk about npm, they can be talking about one of three things. They could be talking about the website, which we've just been looking at. Or they could be talking about the registry, which is a big database of information about packages that people are sharing. Or the third thing they could be talking about is the client: when a developer decides to share their code, they use the npm client which is installed on their computer to publish that code up to the registry. And once there's an entry for this package in the registry, then other developers can use their npm clients to install the package from the registry. The entry in the registry for this package is also reflected on the website, where there's a page dedicated to this new package.

因此由于你已經(jīng)對(duì)npm是做什么的有所了解较店,讓我們談?wù)勊窃趺垂ぷ鞯氖堪恕.?dāng)人們談?wù)搉pm,他們會(huì)談?wù)撊械囊患撼省K麄儠?huì)談?wù)撽P(guān)于我會(huì)看到的網(wǎng)站婚度。或者他們會(huì)談?wù)撟?cè)表官卡,它是關(guān)與人們正在分享的包的巨大的數(shù)據(jù)庫(kù)蝗茁。又或者,他們會(huì)談?wù)摽蛻舳搜爸洌?dāng)一個(gè)開(kāi)發(fā)者決定分享他們的代碼哮翘,他們會(huì)用安裝npm客戶端來(lái)把代碼發(fā)布到注冊(cè)表。一旦注冊(cè)表里存在這個(gè)包的入口仔涩,其他的開(kāi)發(fā)者就可以通過(guò)他們的npm客戶端來(lái)從注冊(cè)表安裝包忍坷。該包的注冊(cè)表入口也會(huì)映射到npm網(wǎng)站上一個(gè)獨(dú)立的頁(yè)面。

Q2:npm能做什么熔脂?

  • 管理代碼包之間的依賴關(guān)系

  • 授權(quán)私人代碼包

Q3 : npm的特點(diǎn)佩研?

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市霞揉,隨后出現(xiàn)的幾起案子旬薯,更是在濱河造成了極大的恐慌,老刑警劉巖适秩,帶你破解...
    沈念sama閱讀 216,324評(píng)論 6 498
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件绊序,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡秽荞,警方通過(guò)查閱死者的電腦和手機(jī)骤公,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 92,356評(píng)論 3 392
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)扬跋,“玉大人阶捆,你說(shuō)我怎么就攤上這事∏仗” “怎么了洒试?”我有些...
    開(kāi)封第一講書人閱讀 162,328評(píng)論 0 353
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)朴上。 經(jīng)常有香客問(wèn)我垒棋,道長(zhǎng),這世上最難降的妖魔是什么痪宰? 我笑而不...
    開(kāi)封第一講書人閱讀 58,147評(píng)論 1 292
  • 正文 為了忘掉前任叼架,我火速辦了婚禮畔裕,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘碉碉。我一直安慰自己柴钻,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,160評(píng)論 6 388
  • 文/花漫 我一把揭開(kāi)白布垢粮。 她就那樣靜靜地躺著贴届,像睡著了一般。 火紅的嫁衣襯著肌膚如雪蜡吧。 梳的紋絲不亂的頭發(fā)上毫蚓,一...
    開(kāi)封第一講書人閱讀 51,115評(píng)論 1 296
  • 那天,我揣著相機(jī)與錄音昔善,去河邊找鬼元潘。 笑死,一個(gè)胖子當(dāng)著我的面吹牛君仆,可吹牛的內(nèi)容都是我干的翩概。 我是一名探鬼主播,決...
    沈念sama閱讀 40,025評(píng)論 3 417
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼返咱,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼钥庇!你這毒婦竟也來(lái)了?” 一聲冷哼從身側(cè)響起咖摹,我...
    開(kāi)封第一講書人閱讀 38,867評(píng)論 0 274
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤评姨,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后萤晴,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體吐句,經(jīng)...
    沈念sama閱讀 45,307評(píng)論 1 310
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,528評(píng)論 2 332
  • 正文 我和宋清朗相戀三年店读,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了嗦枢。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 39,688評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡屯断,死狀恐怖文虏,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情裹纳,我是刑警寧澤,帶...
    沈念sama閱讀 35,409評(píng)論 5 343
  • 正文 年R本政府宣布紧武,位于F島的核電站剃氧,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏阻星。R本人自食惡果不足惜朋鞍,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,001評(píng)論 3 325
  • 文/蒙蒙 一已添、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧滥酥,春花似錦更舞、人聲如沸。這莊子的主人今日做“春日...
    開(kāi)封第一講書人閱讀 31,657評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至瘦真,卻和暖如春刊头,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背诸尽。 一陣腳步聲響...
    開(kāi)封第一講書人閱讀 32,811評(píng)論 1 268
  • 我被黑心中介騙來(lái)泰國(guó)打工原杂, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人您机。 一個(gè)月前我還...
    沈念sama閱讀 47,685評(píng)論 2 368
  • 正文 我出身青樓穿肄,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親际看。 傳聞我的和親對(duì)象是個(gè)殘疾皇子咸产,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,573評(píng)論 2 353

推薦閱讀更多精彩內(nèi)容