macnvm 的安装和使用,解决mac重启node not found,每次都得source ~/.bash_profile

Posted ThinkerWing

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了macnvm 的安装和使用,解决mac重启node not found,每次都得source ~/.bash_profile相关的知识,希望对你有一定的参考价值。

https://segmentfault.com/a/1190000017391932

首先打开终端,进入当前用户的 home 目录中。

cd ~/
然后使用 ls -a 显示这个目录下的所有文件(夹)(包含隐藏文件及文件夹),查看有没有 .bash_profile 这个文件。

ls -a
如果没有,则新建一个。

touch ~/.bash_profile

安装最新版本的nvm

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.38.0/install.sh | bash

一、问题描述
Mac配置好了环境变量文件(.bash_profile)后,每次打开终端都需要执行一遍source ~/.bash_profile才能使环境变量生效,这样很是麻烦;
指的是:在当前shell环境中执行xxx文件中的内容。

二、解决方法
1.创建.zshrc文件(如果已经有了就无须创建)
$ touch .zshrc

2.编辑.zshrc文件
open .zshrc

3.向.zshrc中添加如下内容
source ~/.bash_profile

三、常用命令
https://blog.csdn.net/muguli2008/article/details/107730766

value项目
nvm version查看nvm版本
nvm ls查看所有已经安装的Nodejs版本
nvm list installed查看所有已经安装的版本
nvm ls available查看运程线上所有版本
nvm root查看nvm安装路径
nvm use 版本号切换版本(这个是全局的)
nvm use 12.18.0切换到2.18.0版本
nvm install latest安装最新稳定版Nodejs
nvm install 12.18.0安装指定版本
nvm uninstall 12.18.0卸载指定 12.18.0版本

以上是关于macnvm 的安装和使用,解决mac重启node not found,每次都得source ~/.bash_profile的主要内容,如果未能解决你的问题,请参考以下文章