mac os切换mysql版本_【Node.js】:多版本 Node.js 管理

ed7c24391e26168e556e7ad14ce209d9.png

目录1. 背景?2. Fast Node Manager (fnm)  2.1. 是什么?  2.2. 安装、使用?
1 . 背景?

有些项目对 Node.js 的版本有要求(例如:codesandbox-client 要求 Node.js 版本要兼容 ^10.22.1),这就需要有一种方法能在你的电脑上管理(安装、切换、删除)多个版本的 Node.js。

e6dae2dae6179dfab281b6118ef5ec8f.png

2 . Fast Node Manager (fnm)

2.1. 是什么?

? Fast and simple Node.js version manager, built in Rust.

  • ? Cross-platform support (Mac, Windows, Linux)

  • ✨ Single file, easy installation, instant startup

  • ? Built with speed in mind

  • ? Works with .node-version and .nvmrc files

注:开源项目 codesandbox-client 即推荐使用 fnm 作为 Node.js 的版本管理器。

2.2. 安装、使用?

  • 工作环境:

    • OS:Win10

    • IDE:WebStorm

      • Terminal:PowerShell

  • 下载发布包、配置PATH环境变量

    • https://github.com/Schniz/fnm/releases

b850e8f187dcef4a25de43bee5fe96c0.png

  • 调整 PowerShell,使它可以正常执行 .ps1 文件(PowerShell脚本文件)

    • 操作系统默认不允许执行 .ps1 文件

set-ExecutionPolicy RemoteSigned

a5f66b60f029e496b21ac2b9587c6d39.png

69ed777278b2d22b5b9a49b0600d9a61.png

  • 修改 PowerShell 配置文件,在每次启动 PowerShell 时,对 fnm 进行初始化

    • C:\Users\Administrator\Documents\WindowsPowerShell\profile.ps1

89f34ae595df473fcce755bb71de0afb.png

  • 调整 WebStorm 的 Terminal 为 PowerShell

d0cd147adf5d92d947b6a3deb8ea9d89.png

  • 使用 fnm 安装指定版本 Node.js

    • 使用 --node-dist-mirror 加速下载

fnm install v10.22.1  --node-dist-mirror="https://npm.taobao.org/dist"

b8bf435456d0d46c892e662a21ef9848.png

  • 使用 fnm 切换到指定版本 Node.js

fnm use 10.22.1

402abe60ce65419919a2e9c8a37e9c7c.png

  • 顺利切换版本后,即可正常进行后续工作了

6ebf6fbb78b986122ec1bc36690fad7e.png

参考:

Fast Node Manager (fnm):

https://github.com/Schniz/fnm

PowerShell Execution Policies:

https://docs.microsoft.com/zh-cn/previous-versions/windows/powershell-scripting/hh847748(v=wps.640)

Windows PowerShell Profiles:

https://docs.microsoft.com/en-us/previous-versions//bb613488(v=vs.85)?redirectedfrom=MSDN

a93ab0577b26a84ed11f04996dfb0cb6.png


7a03797f9e08221defc24456642da56a.png  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值