【转载】linux下升级npm以及node
原文:http://blog.csdn.net/qq_16339527/article/details/73008708
npm升级
废话不多说,直接讲步骤。先从容易的开始,升级npm。
npm这款包管理工具虽然一直被人们诟病,很多人都推荐使用yarn,但其使用人数还是不见减少,况且npm都是随node同时安装好的,一时让我抛弃它,还是有点难做到。
npm i -g npm
- 1
是的,你没看错。升级npm只需要像安装其它包一样install一下就行,windows和linux下都可以通过此方式进行升级,你还能指定npm的版本。
npm i -g npm@5.0.0
- 1
node升级
node升级相对于npm来说就复杂一点了。
1、首先通过npm安装node的版本管理工具“n“,不用惊讶,名字就是这么简单,就叫n。据了解,n是node下的一个模块,作者是Express框架的开发者。
npm i -g n
- 1
2、检查n模块
先查看系统node的安装路径,n模块的默认路径为 ‘/usr/local’。
$ which node
/data/home/server/nodejs/bin/node #举个例子
- 1
- 2
- 3
如果路径与n模块的默认路径相同可以跳过3步骤。
3、通过N_PREFIX变量来修改 n 的默认node安装路径。
(1) 编辑环境配置文件
vim ~/.bash_profile
- 1
(2) 将下面两行代码插入到文件末尾
export N_PREFIX=/data/home/server/nodejs #node实际安装位置
export PATH=$N_PREFIX/bin:$PATH
- 1
- 2
(3) :wq保存退出;
执行source使修改生效。
$ source ~/.bash_profile
- 1
(4) 确认一下环境变量是否生效。
echo $N_PREFIX
/data/home/server/nodejs
- 1
- 2
4、n模块常用命令
Commands:
n Output versions installed
n latest Install or activate the latest node release
n -a x86 latest As above but force 32 bit architecture
n stable Install or activate the latest stable node release
n lts Install or activate the latest LTS node release
n <version> Install node <version>
n use <version> [args ...] Execute node <version> with [args ...]
n bin <version> Output bin path for <version>
n rm <version ...> Remove the given version(s)
n prune Remove all versions except the current version
n --latest Output the latest node version available
n --stable Output the latest stable node version available
n --lts Output the latest LTS node version available
n ls Output the versions of node available
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
(1) 安装node最新版本
n latest
- 1
(2) 安装稳定版
n stable
- 1
(3) 安装指定版本
n v7.10.0
- 1
(4) 查看已安装版本
n
- 1
(5) 删除指定版本
n rm 6.4.0
- 1
最后,linux下还有一款基于shell的node管理工具nvm,有兴趣的同学也可以自己尝试下。
【转载】linux下升级npm以及node的更多相关文章
- linux下升级npm以及node
npm升级 废话不多说,直接讲步骤.先从容易的开始,升级npm. npm这款包管理工具虽然一直被人们诟病,很多人都推荐使用yarn,但其使用人数还是不见减少,况且npm都是随node同时安装好的,一时 ...
- [转载]Linux下非root用户如何安装软件
[转载]Linux下非root用户如何安装软件 来源:https://tlanyan.me/work-with-linux-without-root-permission/ 这是本人遇到的实际问题,之 ...
- linux下安装以及升级npm,node的方法
1.最开始使用阿里云文档提供的安装方法一直都是失败的状态,后来找到了新的方法重新安装,按照以下操作一步一步的走即可实现,亲测可用 2.安装完之后,会发现npm和node的版本都偏低,需要重新升级以下, ...
- [转载]linux下svn常用指令
一下内容转载于:http://blog.chinaunix.net/space.php?uid=22976768&do=blog&id=1640924.这个总结的很好~ windows ...
- 转载-Linux下搭建VPN服务器(CentOS、pptp)
转自:http://www.cnblogs.com/sixiweb/archive/2012/11/20/2778732.html 搭建过程参考这篇文章 先说我搭建过程中出现的问题吧: 按照 教程搭建 ...
- windows 下更新 npm 和 node
原文链接 公司的新项目要启动了,需要使用 Angular 4.0,并且使用 webpack 工具进行打包.所以就需要安装 node.node 的安装很简单,在 node 的官网 nodejs.org ...
- linux下用命令安装node&pm2
我的安装环境是腾讯云centos7操作系统,并且将安装包下载到了/usr/local/src目录下 一.下载node安装包 1.wget https://npm.taobao.org/mirrors/ ...
- Linux下升级Python到3.5.2版本
原文出处:https://www.cnblogs.com/tssc/p/7762998.html 本文主要介绍在Linux(CentOS)下将Python的版本升级为3.5.2的方法 众所周知,在20 ...
- 转载Linux下开启MySQL日志
转载https://blog.csdn.net/weixin_38187469/article/details/79273962 开启mysql日志 1.查看日志是否启用 mysql> sh ...
随机推荐
- vue资源
Vue中文官网:https://cn.vuejs.org/ Vue源码:https://github.com/vuejs/vue Vue官方工具:https://github.com/vuejs vu ...
- 设计模式---对象创建模式之原型模式(prototype)
一:概念 原型模式(Prototype Pattern) 实际上就是动态抽取当前对象运行时的状态 Prototype模式是一种对象创建型模式,它采取复制原型对象的方法来创建对象的实例.使用Protot ...
- Catfish CMS漏洞集合
转自https://larryxi.github.io/ 0x00 背景 版本:V 4.2.35 官网下载:http://www.catfish-cms.com/page/4.html 文章内容仅作学 ...
- JAVA通过继承线性表来实现有序表
1,对于线性表而言,里面的元素是无序的,可以随意地将新元素增加到线性表中而不需要考虑该元素在线性表中的位置.但是,对于有序表而言,其中的元素是按照某种方式进行排序的,因此在有序表中插入元素时,需要按照 ...
- Python入门系列教程(一)基础
基础知识 1.变量及类型 2.换行\n 3.输入 password = raw_input("请输入密码:") print '您刚刚输入的密码是:', password 4.格式化 ...
- WF控制台工作流(1)
简单使用WF工作流示例: using System; using System.Linq; using System.Activities; using System.Activities.State ...
- C# 简单线程实例
1.简单线程实例 以及委托(同步委托.异步委托) using System; using System.Collections.Generic; using System.Linq; using Sy ...
- Linux 文件日志筛选操作
统计查看文件以及筛选日志 1.*.log 日志文件中 统计独立ip的个数: awk '{print $1}' test.log | sort | uniq | wc -l 2.#查询访问最多的前10个 ...
- Python之Eclipse环境下安装与配置
奔着对python的好奇,今天又是周末,欲小试Python.那么首先避不开的问题就是python的环境搭建.而我之前已经在学习Java的过程中安装了Eclipse,不想再安装更多的IDE了,就那Ecl ...
- Centos 6.5 安装Python 3.7
文档下载地址: https://files.cnblogs.com/files/flashBoxer/Centos6.5%E5%AE%89%E8%A3%85Python3.7.xml