美文网首页
Mac npm、node 安装与更新

Mac npm、node 安装与更新

作者: 黏着Leon的小尾巴 | 来源:发表于2019-03-13 17:39 被阅读0次

npm 安装

homebrew 方式:brew install npm

# 使用淘宝镜像
# 支持 npm 除了 publish 之外的所有命令
# 如果 npm 安装缓慢或失败,可使用 cnpm
sudo npm install -g cnpm --registry=https://registry.npm.taobao.org

# 查看版本
cnpm -v

查看版本

本地版本:npm -v

npm outdated 检查模块是否已经过时

image

更新版本

最新版本:sudo npm -g install npm@latest
指定版本:sudo npm -g install npm@6.0.0

常用命令

npm help # 查看某条命令的详细帮助
npm install # 安装模块
npm uninstall # 卸载模块
npm update # 更新模块
npm start # 启动模块
npm stop # 停止模块
npm restart # 重新启动模块
npm test # 测试模块
npm version # 查看模块版本

node 安装

—— node 版本管理工具

n

https://github.com/tj/n

  1. 清除 node.js cache:sudo npm cache clean -f
  2. 安装 n 工具(node.js 版本管理工具):sudo npm install -g n
  3. 安装稳定版:sudo n stable
  4. 查看 node 版本:node -v

安装稳定版本:sudo n stable
安装指定版本:sudo n v8.0.0
删除指定版本:sudo n rm v8.0.0

nvm

https://github.com/creationix/nvm

  1. brew install nvm
  2. 在 shell 配置文件(~/.bashrc 或 ~/.zshrc)中添加以下内容:
    # 在 shell 中使用 nvm 指令
    # 查看官方最新说明:https://github.com/creationix/nvm#manual-install
    export NVM_DIR="$HOME/.nvm"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
    
  3. 重新source
    . ~/.bashrc
    . ~/.zshrc

安装稳定版本:sudo nvm install stable
安装指定版本:sudo nvm install v8.0.0
删除指定版本:sudo nvm uninstall v8.0.0

列出本地版本:nvm ls
切换本地版本:nvm use v8.0.0

n 与 nvm

n

  1. 不支持 win
  2. node 模块,安装简单
  3. n 切换版本时,共用全局的 node/npm 目录

nvm

  1. 更加流行
  2. shell 脚本,需要手动指定路径
  3. 不同版本都会安装自有的 node 模块(版本间不冲突,但占用硬盘资源)

普通用户二选一即可,专业开发建议使用 nvm。

相关文章

  • npm安装依赖包

    mac下安装npm npm查看版本 npm安装node模块 npm本地安装lodash 安装包放在 ./node_...

  • Mac npm、node 安装与更新

    npm 安装 homebrew 方式:brew install npm 查看版本 本地版本:npm -v npm ...

  • mac上快速集成weexsdk 

    1.首先在mac上安装node和npm 可参考mac上安装nodejs和npm 2. 查看node和npm版本号...

  • 2018-12-17

    卸载安装node npm (Mac linux ) 1. 卸载node npm (1) 先卸载 npm: s...

  • Mac下ionic环境

    背景:ionic更新频繁,直接更新报错,直接删掉node,npm和ionic,重新安装。 1.安装npm和node...

  • Vue 入门之安装(Mac)

    Vue 入门之安装(Mac) Step 1 安装npm,npm全称为Node Package Manager,是一...

  • Hexo博客搭建

    环境 Mac os安装Homebrewg软件包 安装Node.js 安装Git 查看node npm git 版本...

  • 一:安装dva-cli

    首先确保电脑已安装node、npm 1. npm install dva-cli -g mac下安装...

  • 2018-03-27 智能合约truffle初体验 -by sk

    0. 准备,安装node, npm 安装brew,brew是mac平台软件安装工具 通过brew安装node,no...

  • Vue 环境安装及配置

    安装开发环境 Mac 更新brew 安装 node 下载示例程序,使用npm编译并成功运行,在浏览器上正常显示 下...

网友评论

      本文标题:Mac npm、node 安装与更新

      本文链接:https://www.haomeiwen.com/subject/hvvtmqtx.html