npm安装依赖太慢问题

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了npm安装依赖太慢问题相关的知识,希望对你有一定的参考价值。

执行 npm install 会发现很慢,可以在安装时手动指定从哪个镜像服务器获取资源,我使用的是阿里巴巴在国内的镜像服务器。

命令如下:

npm install --registry=https://registry.npm.taobao.org

避免每次安装都需要--registry参数,可以使用如下命令进行永久设置

npm config set registry https://registry.npm.taobao.org

 执行完命令后,会发现~/.npmrc文件中会加入一条:registry=https://registry.npm.taobao.org

或可以直接编辑  ~/.npmrc 加入下面内容

registry = https://registry.npm.taobao.org

npm info underscore (如果上面配置正确这个命令会有字符串response)

{ name: ‘underscore‘,
  description: ‘javascript\‘s functional programming helper library.‘,
  ‘dist-tags‘: { latest: ‘1.8.3‘, stable: ‘1.8.3‘ },
  maintainers: 
   [ ‘jashkenas <jashkenas@gmail.com>‘,
     ‘jridgewell <justin[email protected]>‘ ],
  time: 
   { modified: ‘2017-03-27T10:13:57.000Z‘,
     created: ‘2011-11-14T20:28:47.115Z‘,
     ‘1.8.3‘: ‘2015-04-02T15:32:54.520Z‘,
     ‘1.8.2‘: ‘2015-02-22T14:14:32.785Z‘,
     ‘1.8.1‘: ‘2015-02-20T03:20:05.519Z‘,
     ‘1.8.0‘: ‘2015-02-20T00:14:01.838Z‘,
     ‘1.7.0‘: ‘2014-08-26T22:16:25.836Z‘,
     ‘1.6.0‘: ‘2014-02-10T21:14:55.838Z‘,
     ‘1.5.2‘: ‘2013-09-07T13:00:28.048Z‘,
     ‘1.5.1‘: ‘2013-07-08T08:38:10.051Z‘,
     ‘1.5.0‘: ‘2013-07-06T18:05:58.721Z‘,
     ‘1.4.4‘: ‘2013-01-30T02:12:42.969Z‘,
     ‘1.4.3‘: ‘2012-12-04T18:47:36.401Z‘,
     ‘1.4.2‘: ‘2012-10-07T03:05:02.986Z‘,
     ‘1.4.1‘: ‘2012-10-01T17:20:22.595Z‘,
     ‘1.4.0‘: ‘2012-09-27T22:02:55.267Z‘,
     ‘1.3.3‘: ‘2012-04-10T14:43:48.089Z‘,
     ‘1.3.2‘: ‘2012-04-09T18:38:14.345Z‘,
     ‘1.3.1‘: ‘2012-01-23T22:57:36.474Z‘,
     ‘1.3.0‘: ‘2012-01-11T16:41:38.459Z‘,
     ‘1.2.4‘: ‘2012-01-09T17:23:14.818Z‘,
     ‘1.0.4‘: ‘2011-12-07T15:12:18.045Z‘,
     ‘1.2.3‘: ‘2011-12-07T15:12:18.045Z‘,
     ‘1.0.3‘: ‘2011-12-07T15:12:18.045Z‘,
     ‘1.2.1‘: ‘2011-12-07T15:12:18.045Z‘,
     ‘1.2.0‘: ‘2011-12-07T15:12:18.045Z‘,
     ‘1.1.7‘: ‘2011-12-07T15:12:18.045Z‘,
     ‘1.1.0‘: ‘2011-12-07T15:12:18.045Z‘,
     ‘1.1.5‘: ‘2011-12-07T15:12:18.045Z‘,
     ‘1.1.4‘: ‘2011-12-07T15:12:18.045Z‘,
     ‘1.1.3‘: ‘2011-12-07T15:12:18.045Z‘,
     ‘1.1.2‘: ‘2011-12-07T15:12:18.045Z‘,
     ‘1.1.1‘: ‘2011-12-07T15:12:18.045Z‘,
     ‘1.1.6‘: ‘2011-12-07T15:12:18.045Z‘,
     ‘1.2.2‘: ‘2011-11-14T20:28:47.115Z‘ },
  users: 
   { mvolkmann: true,
     lancehunt: true,
     mikl: true,
     linus: true,
     vasc: true,
     bat: true,
     dmalam: true,
     mbrevoort: true,
     danielr: true,
     rsimoes: true,
     tellnes: true,
     jharding: true,
     fgribreau: true,
     tylerstalder: true,
     pid: true,
     graemef: true,
     gillesruppert: true,
     travishorn: true,
     m42am: true,
     bencevans: true,
     Scryptonite: true,
     konklone: true,
     esp: true,
     bryanburgers: true,
     ehershey: true,
     freethenation: true,
     megadrive: true,
     dannydulai: true,
     lupomontero: true,
     ‘cj.nichols‘: true,
     dbrockman: true,
     maxmaximov: true,
     hyqhyq_3: true,
     zonetti: true,
     cparker15: true,
     lemulot: true,
     mlowe: true,
     chilts: true,
     shanewholloway: true,
     elgs: true,
     eins78: true,
     awaterma: true,
     moonpyk: true,
     raitucarp: true,
     victorquinn: true,
     davidgaya: true,
     netroy: true,
     ‘everywhere.js‘: true,
     tigefa: true,
     spekkionu: true,
     pana: true,
     mhaidarh: true,
     einfallstoll: true,
     mpinteractiv: true,
     simloovoo: true,
     darosh: true,
     landau: true,
     cedrickchee: true,
     tpwk: true,
     claveren: true,
     xtopher: true,
     gammasoft: true,
     lomatek: true,
     ‘thomas-so‘: true,
     oliversalzburg: true,
     nosch: true,
     rod: true,
     vegera: true,
     clintonhalpin: true,
     seldo: true,
     priyaranjan: true,
     cilindrox: true,
     cheeseen: true,
     rrobayna: true,
     rockbot: true,
     casoetan: true,
     ajduke: true,
     protonss: true,
     mgesmundo: true,
     bosspj: true,
     rckbt: true,
     zeusdeux: true,
     jetsetty: true,
     evkline: true,
     bcoe: true,
     nbu: true,
     tehdb: true,
     obihann: true,
     wangxian: true,
     ericlondon: true,
     lanceball: true,
     funroll: true,
     leventkaragol: true,
     beyoung: true,
     axelav: true,
     davidhalldor: true,
     cwonrails: true,
     rnbwd: true,
     cocopas: true,
     imnicosuarez: true,
     furkanom: true,
     andydrew: true,
     mrmakeit: true,
     mmierswa: true,
     jasonw: true,
     adamk: true,
     runningtalus: true,
     sironfoot: true,
     ezhi: true,
     suomiton: true,
     uris77: true,
     ksnieck: true,
     fill: true,
     nithanaroy: true,
     abalandin: true,
     jasonweng: true,
     zenanyoo: true,
     djbrandl: true,
     davidrlee: true,
     dereknelson: true,
     frk1705: true,
     nohponex: true,
     thitinun: true,
     pilsy: true,
     lpgray: true,
     tchey: true,
     arrc: true,
     skinnybrit51: true,
     tmypawa: true,
     tsangint: true,
     smashingeric: true,
     dercoder: true,
     slahav: true,
     mhwchung: true,
     davidrobles: true,
     moxiaohe: true,
     truongpv: true,
     gregoryteach: true,
     goblindegook: true,
     tommyjs7: true,
     adammcarth: true,
     atd: true,
     sroccaserra: true,
     yourhoneysky: true,
     jashkenas: true,
     eliagrady: true,
     jits: true,
     lukecarrier: true,
     knoxpayments: true,
     kingcron: true,
     morewry: true,
     karmadude: true,
     kungkk: true,
     johno: true,
     henryfour: true,
     ‘augusto.altman‘: true,
     jesus81: true,
     mstennett: true,
     cbowdon: true,
     hrmoller: true,
     megawac: true,
     hkbarton: true,
     ‘richard.webb‘: true,
     minchnew: true,
     kickthesky: true,
     alexahdp: true,
     bkimminich: true,
     maobean: true,
     windhamdavid: true,
     piecioshka: true,
     l0n9h02n: true,
     wxnet: true,
     genediazjr: true,
     oakley349: true,
     ascheink: true,
     lellansin: true,
     cwhopkins: true,
     dgarlitt: true,
     congcong: true,
     avinashkoyyana: true,
     rorygreig: true,
     macluvin: true,
     ryanj: true,
     jerryzou: true,
     swak: true,
     gdbtek: true,
     themanspeaker: true,
     stennettm: true,
     netzflechter: true,
     richarddavenport: true,
     thorsson: true,
     kruemelo: true,
     porkbits: true,
     taekgeun: true,
     ikoala: true,
     kenjisan4u: true,
     eterna2: true,
     excentric: true,
     indexzero: true,
     mnemr: true,
     wangnan0610: true,
     jezzalaycock: true,
     midknight41: true,
     devonoel: true,
     caligone: true,
     f124275809: true,
     greendwin: true,
     io2work: true,
     icflorescu: true,
     aitorllj93: true,
     batosai: true,
     stuligan: true,
     sametsisartenep: true,
     craigsapp: true,
     infinitycbs: true,
     tkhemani: true,
     andreaspag: true,
     yasinaydin: true,
     pnevares: true,
     princemaple: true,
     haeck: true,
     j3kz: true,
     pughpugh: true,
     jaggedsoft: true,
     mathieuancelin: true,
     sobering: true,
     vchouhan: true,
     goodseller: true,
     mccarter: true,
     wambulance: true,
     ysk8: true,
     zambon: true,
     skyinlayer: true,
     joeyblue: true,
     jostw: true,
     dpkg: true,
     broxmgs: true,
     chharvey: true,
     seanjh: true,
     plord: true,
     vboctor: true,
     jmm23: true,
     rugare: true,
     blackoperat: true,
     alphavibe: true,
     sharper: true,
     keeyanajones: true,
     subchen: true,
     dongxu: true,
     risyasin: true,
     rbartoli: true,
     lucasmciruzzi: true,
     jakemiller: true,
     huntie: true,
     itonyyo: true,
     jmshahen: true,
     minghe: true,
     chadwatson: true,
     klipsil: true,
     huytard: true,
     orlenka: true,
     makediff: true,
     sbrajesh: true,
     dac2205: true,
     dlaume: true,
     dolymood: true,
     sanketss84: true,
     chriscalo: true,
     richfoxton: true,
     ‘johnny.young‘: true,
     cycomachead: true,
     jimkropa: true,
     damianof: true,
     sonhuytran: true,
     subso: true,
     thepanuto: true,
     imchale: true,
     leejefon: true,
     ernie55ernie: true,
     robermac: true,
     sezgin: true,
     cestrensem: true,
     bpatel: true,
     stevenlothrop: true,
     karlbateman: true,
     fvcproductions: true,
     freshlogic: true,
     kurtz1993: true,
     amaynut: true,
     jqcdq8: true,
     yogapan: true,
     maxime1992: true,
     ‘2dxgujun‘: true,
     dbck: true,
     warapitiya: true,
     nice_body: true,
     jeffb_incontact: true,
     wkaifang: true,
     rvanmil: true,
     ericmash: true,
     vishwasc: true,
     pacotole: true,
     kelerliao: true,
     arnoldstoba: true,
     matthewbauer: true,
     romelperez: true,
     nicwaller: true,
     mamalat: true,
     jozias: true,
     pdedkov: true,
     edwin_estrada: true,
     jasonevrtt: true,
     sky3r: true,
     gollojs: true,
     charlestati: true,
     naokie: true,
     kparkov: true,
     linuxwizard: true,
     zhoutk: true,
     jkrenge: true,
     alectic: true,
     liushoukai: true,
     xeoneux: true,
     wmarra: true,
     andersonsantos: true,
     kobleistvan: true,
     frankxin: true,
     crazyjingling: true,
     eviratec: true,
     nickeltobias: true,
     adonai: true,
     awddwaadzz: true,
     pandao: true,
     dpjayasekara: true,
     ffi: true,
     nystul: true,
     tylerm: true,
     josejaguirre: true,
     maur1th: true,
     piyushmakhija: true,
     jiku: true,
     danielbankhead: true,
     ‘thomas.miele‘: true,
     clisun: true,
     ‘leandro.rosagf‘: true,
     jerous: true,
     dittodhole: true,
     itskdk: true,
     wulfgarpro: true,
     richardcfelix: true,
     digitalextremist: true,
     crabb: true,
     sparkrico: true,
     cfleschhut: true,
     rwhogg: true,
     thiagoh: true,
     hacksalot: true,
     shlomi: true,
     tobiasnickel: true,
     gr4vy: true,
     corca: true,
     wfcookie: true,
     ychang225: true,
     davidbraun: true,
     lukaserat: true,
     jyounce: true,
     bhenav: true,
     ragex1337: true,
     timdp: true,
     novalu: true,
     doptrois: true,
     arbazsiddiqui: true,
     donvercety: true,
     miketr2000: true,
     demod: true,
     kshvmdn: true,
     qddegtya: true,
     hughescr: true,
     lionet: true,
     ceogavin: true,
     wander_lp: true,
     demopark: true,
     nexume: true,
     apehead: true,
     vamakoda: true,
     prestorondo: true,
     markoni: true,
     hgbabu: true,
     philiiiiiipp: true,
     lex_nel: true,
     coalesce: true,
     vinta: true,
     ‘roman-io‘: true,
     sternelee: true,
     lisafrench: true,
     pruettti: true,
     dnik: true,
     dmikam: true,
     jasonwang1888: true,
     asm2hex: true,
     kimkee: true,
     aldofunes: true,
     dabin: true,
     ezeikel: true,
     mseminatore: true,
     monjer: true,
     potnox: true,
     ahadb: true,
     garustar: true,
     martii: true,
     riteshg: true,
     ‘tin-lek‘: true,
     heyimeugene: true,
     binq: true,
     fasdgoc: true,
     jrockowitz: true,
     icerainnuaa: true,
     akinjide: true,
     kaapex: true,
     apwn: true,
     ekmpls: true,
     merrickp: true,
     qinbx: true,
     amdsouza92: true,
     hyokosdeveloper: true,
     muroc: true,
     xxsnake28: true,
     davidcaballeroj: true,
     almgwary: true,
     sopov: true,
     mryeol: true,
     mcl: true,
     faraoman: true,
     frankwinter: true,
     vzonys: true,
     samersm: true,
     prashanta: true,
     gejiawen: true,
     ungurys: true,
     razr9: true,
     ‘ivan.marquez‘: true,
     brainpoint: true,
     apopek: true,
     roxnz: true,
     ‘alex-the-dev‘: true,
     katsos: true,
     ironmaniiith: true,
     rocket0191: true,
     shahyar: true,
     ramzesucr: true,
     zanner: true,
     degouville: true,
     tmurngon: true,
     pfuri: true,
     danielbayley: true,
     krabello: true,
     dburdese: true,
     eijs: true,
     erniep888: true,
     prbsas: true,
     ‘alexey-mish‘: true,
     mobeicaoyuan: true,
     luiscauro: true,
     onursumer: true,
     iandstanley: true,
     mojaray2k: true,
     fahadjadoon: true,
     igorsetsfire: true,
     wgao19: true,
     ahshum: true,
     ‘langri-sha‘: true,
     wenhsiaoyi: true,
     ‘a.sanchez‘: true,
     adilalam: true,
     danielmihai: true,
     adamdreszer: true,
     bapinney: true,
     tunjos: true,
     rylan_yan: true,
     austinbillings: true,
     bobxuyang: true,
     charlietango592: true,
     wearevilla: true,
     prime156: true,
     ahmetertem: true,
     pixelcraft: true,
     jad96: true,
     morogasper: true,
     skellertor: true,
     anoubis: true,
     bengineer: true,
     jasonleewilson: true,
     ukrbublik: true,
     onursimsek: true,
     arvindrsingh: true,
     xmalinov: true,
     cvc: true,
     olonam: true,
     madalozzo: true,
     ‘s.well‘: true,
     sprybear: true,
     chinawolf_wyp: true,
     lunaroyster: true,
     warcrydoggie: true,
     abernier: true,
     vinnyfonseca: true,
     junos: true,
     blackrocky: true,
     icodeforcookies: true,
     noncreature0714: true,
     menoncello: true,
     anipendakur: true,
     nilz3ro: true,
     fabrianibrahim: true,
     iceriver2: true,
     toszter: true,
     blakeredwolf: true,
     heartnett: true,
     maxwelldu: true,
     adammc: true,
     modood: true,
     lusai: true,
     sibawite: true,
     gwilison: true,
     valenwave: true,
     pddivine: true,
     clivend: true,
     maycon_ribeiro: true,
     zhbyak47: true,
     yifan: true,
     manojkhannakm: true,
     julianomontini: true,
     sahlzen: true,
     asj1992: true,
     rdca84: true,
     billl89: true,
     anaumidis: true,
     ericteng177: true,
     thangakumar: true,
     neo1: true,
     hehaiyang: true,
     infernocloud: true,
     largepuma: true,
     krostyslav: true,
     waspar: true,
     marinear212: true,
     ‘npm-packages‘: true,
     tonerbarato: true,
     deepakpund: true,
     iamninad: true,
     vision_tecnologica: true,
     gresite_piscinas: true,
     suryasaripalli: true,
     kwcjr: true,
     colageno: true,
     zwwggg: true,
     aaamitsingh: true,
     vapeadores: true,
     dangmin: true },
  author: ‘Jeremy Ashkenas <jeremy@documentcloud.org>‘,
  repository: 
   { type: ‘git‘,
     url: ‘git://github.com/jashkenas/underscore.git‘ },
  versions: 
   [ ‘1.0.3‘,
     ‘1.0.4‘,
     ‘1.1.0‘,
     ‘1.1.1‘,
     ‘1.1.2‘,
     ‘1.1.3‘,
     ‘1.1.4‘,
     ‘1.1.5‘,
     ‘1.1.6‘,
     ‘1.1.7‘,
     ‘1.2.0‘,
     ‘1.2.1‘,
     ‘1.2.2‘,
     ‘1.2.3‘,
     ‘1.2.4‘,
     ‘1.3.0‘,
     ‘1.3.1‘,
     ‘1.3.2‘,
     ‘1.3.3‘,
     ‘1.4.0‘,
     ‘1.4.1‘,
     ‘1.4.2‘,
     ‘1.4.3‘,
     ‘1.4.4‘,
     ‘1.5.0‘,
     ‘1.5.1‘,
     ‘1.5.2‘,
     ‘1.6.0‘,
     ‘1.7.0‘,
     ‘1.8.0‘,
     ‘1.8.1‘,
     ‘1.8.2‘,
     ‘1.8.3‘ ],
  homepage: ‘http://underscorejs.org‘,
  bugs: { url: ‘https://github.com/jashkenas/underscore/issues‘ },
  license: ‘MIT‘,
  keywords: [ ‘util‘, ‘functional‘, ‘server‘, ‘client‘, ‘browser‘ ],
  main: ‘underscore.js‘,
  version: ‘1.8.3‘,
  devDependencies: 
   { docco: ‘*‘,
     eslint: ‘0.6.x‘,
     karma: ‘~0.12.31‘,
     ‘karma-qunit‘: ‘~0.1.4‘,
     ‘qunit-cli‘: ‘~0.2.0‘,
     ‘uglify-js‘: ‘2.4.x‘ },
  scripts: 
   { test: ‘npm run test-node && npm run lint‘,
     lint: ‘eslint underscore.js test/*.js‘,
     ‘test-node‘: ‘qunit-cli test/*.js‘,
     ‘test-browser‘: ‘npm i karma-phantomjs-launcher && ./node_modules/karma/bin/karma start‘,
     build: ‘uglifyjs underscore.js -c "evaluate=false" --comments "/    .*/" -m --source-map underscore-min.map -o underscore-min.js‘,
     doc: ‘docco underscore.js‘ },
  files: 
   [ ‘underscore.js‘,
     ‘underscore-min.js‘,
     ‘underscore-min.map‘,
     ‘LICENSE‘ ],
  gitHead: ‘e4743ab712b8ab42ad4ccb48b155034d02394e4d‘,
  dist: 
   { shasum: ‘4f3fb53b106e6097fcf9cb4109f2a5e9bdfa5022‘,
     size: 34172,
     noattachment: false,
     tarball: ‘http://registry.npm.taobao.org/underscore/download/underscore-1.8.3.tgz‘ },
  directories: {},
  publish_time: 1427988774520 }

 

以上是关于npm安装依赖太慢问题的主要内容,如果未能解决你的问题,请参考以下文章

npm速度过慢的解决方案

nrm管理npm源

安装 NPM 导航依赖包安装时出错

React中 npm start出现问题的情况解决

如何让 npm 从 GitHub url 安装 typescript 依赖项?

Yarn: 一个新的JavaScript模块管理器