ÁÄÁÄÔõôʹÓÃnpm×°ÖÃGithubÄ£¿é
Ëæ×ÅgithubµÄÊ¢ÐкÍʹÓã¬Ô½À´Ô½¶àµÄÈ˶¼×îÏÈʹÓÃËü¾ÙÐÐÏîÄ¿ÖÎÀíÒÔ¼°Ð×÷¿ª·¢¡£npm (node package manager)ÊÇÒ»¸ö¼«ÆäÊ¢ÐÐµÄ javascript °ü¹ÜÀíÆ÷£¬ÈÃÎÒÃÇÄܹ»ÇáËɵع²ÏíºÍ×éÖ¯ÎÒÃǵĴúÂë¡£Òò´Ë£¬½«githubºÍnpmÍŽáʹÓ㬿ÉÒÔΪÎÒÃǵÄÏîÄ¿¿â´øÀ´¸ü¶àµÄ±ãµ±ÐԺͿɶ¨ÖÆ»¯¡£
ÈôÊÇÄúÏëÒª½«ÄúµÄGithub´úÂë¿âתÄð³ÉÒ»¸ö°ü£¬ÒÔ±ãÔÚÆäËûÏîÄ¿ÖÐÖظ´Ê¹Óã¬Ç¿ÁÒ½¨ÒéÄúʹÓÃNPM¡£ÓÉÓÚNPMÊÇÄ¿½ñ×îÊ¢ÐеÄJavaScriptÈí¼þ°ü¹ÜÀíÆ÷Ö®Ò»£¬Òò´Ë£¬½èÖúËü¿ÉÒÔÀû±ãµØ½«GithubÉϵĴúÂë¿âת»»ÎªÄ£¿é²¢ÔÚNPMÉÏÐû²¼¡£
±¾ÎĽ«ÏÈÈÝÔõÑùÔÚNPMÉÏ×°ÖÃGithubÄ£¿é¡£Çëƾ֤ÒÔÏ°취²Ù×÷£º
µÚÒ»²½£ºÔÚGithubÉϽ¨Éè²¢Ðû²¼ÄúµÄ´úÂë¿â
ÔÚÄúµÄGithubСÎÒ˽ÈËÕË»§Öн¨ÉèÒ»¸öеĴúÂë¿â£¬Ëæºó½«ÄúµÄ´úÂëÍÆË͵½¸Ã¿âÖС£
µÚ¶þ²½£ºÔÚÏÂÁîÐÐÖÐÔËÐÐnpm init
½øÈëÏÂÁîÐУ¬²¢ÔÚÏÂÁîÐÐÖÐÊäÈë¡°npm init¡±ÏÂÁî¡£Õ⽫Æô¶¯Ò»¸öÏòµ¼£¬Ö¸ÒýÄúÍê³É½¨ÉèÒ»¸öNode.jsÏîÄ¿µÄÀú³Ì¡£ÄúÐèÒªÊäÈëÄúÏîÄ¿µÄÃû³Æ¡¢ÐÎòÒÔ¼°°æ±¾µÈÐÅÏ¢¡£Ò»µ©ÄúÍê³ÉÁËÕâЩÐÅÏ¢µÄÌîд£¬¾Í»á×Ô¶¯ÌìÉúÒ»¸öpackage.jsonÎļþ£¬ÆäÖаüÀ¨ÏîÄ¿µÄËùÓÐÐÅÏ¢¡£
µÚÈý²½£º½«GithubÁ´½ÓÌí¼Óµ½package.jsonÎļþ
ÔÚpackage.jsonÎļþÖÐÕÒµ½¡°dependencies¡±×ֶΣ¬½«ÄúµÄGithub´úÂë¿âÁ´½ÓÌí¼Óµ½ÆäÖС£
{ "name": "npm-github-install-examples", "version": "1.0.0", "description": "Demonstrates installing GitHub repos as NPM packages.", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "author": "", "license": "ISC", "dependencies": { "github-org/repo-name": "1.0.0" } }
µÇ¼ºó¸´ÖÆ
ÔÚÕâÀïÎÒÌí¼ÓÁËÃûΪ”github-org/repo-name”µÄGithub´úÂë¿âÁ´½Ó£¬Æä°æ±¾Îª¡°1.0.0¡±¡£
µÚËIJ½£ºÔËÐÐnpm install
ÔÚÏÂÁîÐÐÖÐÊäÈë¡°npm install¡±ÏÂÁîÒÔ×°ÖÃÕâ¸öGithub´úÂë¿â¡£Õ⽫ÔÚÄúµÄÏîÄ¿ÖÐ×°ÖÃÃûΪ¡°github-org/repo-name¡±µÄÄ£¿é¡£
npm install
µÇ¼ºó¸´ÖÆ
ÏÖÔÚ£¬ÄúÒѾ¿ÉÒÔʹÓÃÕâ¸ö´úÂë¿âÁË£¡
×ܽ᣺
ÎÒÃÇÒѾÏêϸÏÈÈÝÁËÔõÑù½«Github´úÂë¿âת»»ÎªÄ£¿é£¬²¢ÇÒÏÈÈÝÁËÔõÑùÔÚNPMÉÏ×°ÖÃÕâ¸öÄ£¿é¡£ÔÚ½ñÌìµÄJavaScriptÌìÏÂÖУ¬GithubÒѾ³ÉΪÁË¿ª·¢ÕßÃǹ²ÏíºÍÐ×÷¿ª·¢µÄÖ÷Ҫƽ̨£¬¶øNPMÔòÊÇÈÃÎÒÃÇÄܹ»¸üÀû±ãµØ·ÖÏíºÍ×éÖ¯ÎÒÃǵĴúÂë¡£ÒÔÊÇ£¬½«ÕâÁ½¸ö¹¤¾ßÍŽáʹÓý«ÎªÎÒÃÇ´øÀ´¸ü¶àµÄ±ãµ±ÐԺͿɶ¨ÖÆ»¯¡£
ÒÔÉϾÍÊÇÁÄÁÄÔõôʹÓÃnpm×°ÖÃGithubÄ£¿éµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡