zoukankan      html  css  js  c++  java
  • npm下载包很慢和node-sass编译错误的解决办法

    最近研究一个ionic cordova angular2的前端项目 发现npm install下载包非常慢的问题 最近整理了一些解决这些问题的方法。

    1.通过config命令修改https为http

    
    
    npm config set registry http://registry.npmjs.org  npm info underscore
    
    
    

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

    2.命令行指定

    
    
    npm --registry http://registry.cnpmjs.org info underscore
    
    
    
    
    

    3.使用淘宝镜像地址

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

      

    如果上面的npm地址不行的话,大家可以参考一下方式

    地址:http://www.uedbox.com/npm-install-slow-solution/

    遇到问题解决如下:

    由于某些不可描述的原因,利用npm进行安装模块的时候会发生xxx下载失败的情况node-sass尤其的频繁,或者说node-sass的二进制文件是接近百分百失败的,即使用yarn安装也依旧在这个点失败,以下是完整的解决方案。

    方案一:

      首先,我们需要提前下载node-sass的二进制文件,这个文件可以去cnpm仓库下载或者node-sass的github上去下载,在下载之前我们需要先查看电脑的系统的版本,来确定适合哪个版本的二进制文件,查看版本的指令如下:

    node -p "[process.platform, process.arch, process.versions.modules].join('-')"

    输入这个指令后会弹出一个系统版本,比如我这弹出的是 win32-x64-48,则我就需要去以下两个地址中任意一个下载 win32-x64-48_binding.node 这个文件(后缀为node的文件)到本地:

      cnpm: https://npm.taobao.org/mirrors/node-sass/

      github: https://github.com/sass/node-sass/releases

    下载完保存到任意位置,最好放置到package.json所在位置。然后我们需要手动指定node-sass二进制文件的下载源为下载的那个文件(比如我的是在e盘下的web文件夹内),以下是npm与yanr的指令:

    npm:

    npm config set sass-binary-path e:/web/win32-x64-48_binding.node

    yran:

    yarn config set sass-binary-path e:/web/win32-x64-48_binding.node

    然后我们即可用正常指令下载了。注意:此方法会绑定为本地文件,即无法更新node-sass了~~如果不希望这么做,请使用第二种方案。

    站长推荐:

    方案二:

    此方案将把下载源指定为cnpm仓库:

    全部的下载源指向cnpm的指令:

      npm :

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

      yarn :

    yarn config set registry http://registry.npm.taobao.org

     只指定node-sass的下载源:

      npm:

    npm config set sass-binary-site http://npm.taobao.org/mirrors/node-sass

      yarn:

    yarn config set sass-binary-site http://npm.taobao.org/mirrors/node-sass

      然后我可以正常使用npm或者yarn进行下载了~

    最后,关于如何使用cnpm代替npm。。。。直接npm install cnpm -g就好了-。-~~~~  然后就可以直接用cnpm install XXX等指令安装了。

    最后使用  cnpm install node-sass 下载这个插件就好了。 

  • 相关阅读:
    基于摸板匹配的目標跟蹤算法
    spoj 2713 Can you answer these queries IV
    zoj 3633 Alice's present
    hdu 3642 Get The Treasury
    poj 1195 Mobile phones
    poj 2760 End of Windless Days
    zoj 3540 Adding New Machine
    spoj 1716 Can you answer these queries III
    spoj 1043 Can you answer these queries I
    spoj 2916 Can you answer these queries V
  • 原文地址:https://www.cnblogs.com/owenma/p/7487067.html
Copyright © 2011-2022 走看看