zoukankan      html  css  js  c++  java
  • 原文链接为: https://blog.csdn.net/wangtaoking1/article/details/78005038

    这篇文章介绍如何在ubuntu环境下安装node环境。

    我使用的系统是ubuntu 16.04,不过在其他版本的系统中应该也适用。

    安装python-software-properties

    首先需要安装依赖包python-software-properties。

    $ sudo apt-get install python-software-properties
    

    添加PPA

    网站deb.nodesource.com维护了nodejs的各版本安装包的PPA,我们可以从该网站上下载执行导入。

    $ curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
    

    如果提示没有安装curl,需要先安装curl。 
    当前6.x版本为比较稳定的版本,我们可以根据自己的需要选择安装不同的版本。

    安装nodejs和npm

    接下来安装nodejs,安装完成之后npm也自动安装好了。

    $ sudo apt-get install nodejs
    

    安装完成之后我们查看一下nodejs和npm的版本。

    $ node -v
    v8.5.0
    $ npm -v
    v5.3.0
    

    配置npm仓库

    因为国内的网络环境,直接从npm官方源安装软件包速度会比较慢,甚至导致安装不成功。 
    我们可以安装nrm工具,用于管理软件源。

    $ npm install -g nrm
    

    安装完成之后,列出可用的软件源

    $ nrm ls
    * npm ---- https://registry.npmjs.org/
      cnpm --- http://r.cnpmjs.org/
      taobao - https://registry.npm.taobao.org/
      nj ----- https://registry.nodejitsu.com/
      rednpm - http://registry.mirror.cqupt.edu.cn/
      npmMirror  https://skimdb.npmjs.com/registry/
      edunpm - http://registry.enpmjs.org/
    

    在国内,我们可以使用taobao的源,速度还相对不错。

    $ nrm use taobao
    
    Registry has been set to: https://registry.npm.taobao.org/
    

    配置代理

    另外,如果在特定网络环境下需要配置代理的话,可以使用如下命令配置。

    $ npm config set proxy http://127.0.0.1:3128
    $ npm config set http-proxy http://127.0.0.1:3128
    $ npm config set https-proxy https://127.0.0.1:3128
    

    配置代理的方法在windows环境下也是适用的。

  • 相关阅读:
    RxJava API使用示例
    使用create-react-app模板模仿12306app
    web 基本概念辨异 —— URI 与 URL
    RESTful 架构与 RESTful 服务
    python startswith和endswith
    python enumerate函数用法
    python中PIL.Image和OpenCV图像格式相互转换
    Linux查看当前在线用户信息
    Linux查看GPU信息和使用情况
    python中的编码和解码
  • 原文地址:https://www.cnblogs.com/atuotuo/p/9665361.html
Copyright © 2011-2022 走看看