美文网首页
如何在windows下安装特定版本的node?

如何在windows下安装特定版本的node?

作者: 恺雯 | 来源:发表于2020-09-09 15:14 被阅读0次

    step 1——安装nvm

    option 1:在nvm官网上下载nvm-setup.zip安装包,然后运行安装

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

    step 2——查看nvm命令

    在命令行(比如,Git bash)输入nvm --version

    通常此时,会得到nvm: command not found的回答,因为还没有配置环境变量。

    step 3——配置环境变量

    此电脑右键>属性>高级系统设置:

    可以看到在安装nvm时,就已经帮我们配置好了环境变量。

    我们还需要做的是:

    create .bash_profile file


    cd ~

    touch .bash_profile

    open the file you just created


    open .bash_profile //for mac

    vim .bash_profile //for windows Git bash

    paste the following code inside the file


    export NVM_DIR=~/.nvm

    source ~/.nvm/nvm.sh

    run the source command after saving


    source .bash_profile

    then enter the command


    nvm --version

    Then the version number of nvm will appear.

    step 5——安装python

    比如之前通过nodejs官网下载安装的node版本为此时最新的12.x,项目需要换成10.x,则:

    nvm install 10.22.0

    发现安装失败,提示exec: python not found,好吧,需要现安装python。

    从官网上下载安装python:

    在命令行中输入python --version,得到python command not found,说明需要配置环境变量。

    打开安装python时的路径,比如C:\Program Files(x86)\Python38-32,确保里面有python.exe文件。

    把C:\Program Files(x86)\Python38-32复制到Path环境变量中,并确保其在第一个,如果不是第一个,则依旧会得到python command not found。

    然后再查看python --version,此时显示Python3.8.5,成功。

    step 5——安装某特定版本node

    话不多说,上图:

    关于另一个node版本管理工具——n

    n对windows的支持不好,即使用npm install -g n --force强制安装了n,在n v10.22.0安装某一版本是也会提示Git Bash not support n。

    相关文章

      网友评论

          本文标题:如何在windows下安装特定版本的node?

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