美文网首页
Mac 查看 nvm(Node Version Manager)

Mac 查看 nvm(Node Version Manager)

作者: _浅墨_ | 来源:发表于2024-07-05 22:53 被阅读0次

在 macOS 上,nvm(Node Version Manager)的配置文件是.bashrc或者.bash_profile,取决于你当前使用的shell环境。

查看和编辑配置文件

  1. 打开.bashrc.bash_profile文件:

    nano ~/.bashrc
    

    或者

    nano ~/.bash_profile
    
  2. 查找nvm初始化脚本:

    在打开的文件中查找是否有与nvm相关的初始化脚本。通常会看到类似以下内容:

    export NVM_DIR="$HOME/.nvm"
    [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
    [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion
    
  3. 保存文件:

    如果需要对配置文件进行修改或添加nvm相关的内容,可以在编辑器中进行更改后保存文件。

  4. 使更改生效:

    保存文件后,退出编辑器,并运行以下命令使配置文件的更改生效:

    source ~/.bashrc
    

    或者

    source ~/.bash_profile
    

注意事项

  • 如果同时存在.bashrc.bash_profile,只有其中一个会被加载,具体加载哪一个取决于你的shell环境设置。
  • 在进行更改前,建议备份配置文件以防止意外情况发生。
  • 根据不同的需求,有时可能需要修改其他文件或创建新的配置文件来适应自己的环境。

通过编辑和更新nvm在mac上的配置文件,你可以对Node.js版本管理工具nvm进行定制化设置,以满足个人需求和项目要求。

bash_profile内容:

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"


alias mysql='/usr/local/mysql/bin/mysql'
alias mysqladmin='/usr/local/mysql/bin/mysqladmin'
alias mysqlserver='sudo /usr/local/mysql/support-files/mysql.server'


source $(brew --prefix nvm)/nvm.sh

# Created by mirror-config-china
export IOJS_ORG_MIRROR=https://npm.taobao.org/mirrors/iojs
export NODIST_IOJS_MIRROR=https://npm.taobao.org/mirrors/iojs
export NVM_IOJS_ORG_MIRROR=https://npm.taobao.org/mirrors/iojs
export NVMW_IOJS_ORG_MIRROR=https://npm.taobao.org/mirrors/iojs
export NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node
export NODIST_NODE_MIRROR=https://npm.taobao.org/mirrors/node
export NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node
export NVMW_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node
export NVMW_NPM_MIRROR=https://npm.taobao.org/mirrors/npm
# End of mirror-config-china



function proxy_on(){
    export http_proxy=http://127.0.0.1:1087
    export https_proxy=http://127.0.0.1:1087
    echo -e "已开启代理"
}
function proxy_off(){
    unset http_proxy
    unset https_proxy
    echo -e "已关闭代理"
}


# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/changyou/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/Users/changyou/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/Users/changyou/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/Users/changyou/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<

.zshrc 内容

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/changyou/anaconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/Users/changyou/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/Users/changyou/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/Users/changyou/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<


export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion


相关文章

网友评论

      本文标题:Mac 查看 nvm(Node Version Manager)

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