背景简介
使用 conda 管理 nodejs 运行环境
环境信息
- Conda 已安装 【Conda - 安装】
详细步骤
第一步: 查询可用 nodejs 版本信息
$ conda search nodejs
Loading channels: done
# Name Version Build Channel
nodejs 6.11.2 h3db8ef7_0 pkgs/main
nodejs 8.9.3 h439df22_0 pkgs/main
nodejs 8.11.1 hf484d3e_0 pkgs/main
nodejs 8.11.3 hf484d3e_0 pkgs/main
nodejs 8.11.4 he6710b0_0 pkgs/main
nodejs 8.12.0 he6710b0_0 pkgs/main
nodejs 10.13.0 he6710b0_0 pkgs/main
nodejs 14.8.0 hda19d22_0 pkgs/main
nodejs 16.6.1 hb931c9a_0 pkgs/main
nodejs 16.13.1 hb931c9a_0 pkgs/main
nodejs 18.15.0 ha637b67_0 pkgs/main
nodejs 18.16.0 h2d74bed_0 pkgs/main
nodejs 18.16.0 h2d74bed_1 pkgs/main
nodejs 18.16.0 ha637b67_1 pkgs/main
nodejs 18.18.2 h2d74bed_0 pkgs/main
nodejs 20.17.0 hb8e3597_0 pkgs/main
第二步: 根据自身需要安装对应版本的 nodejs
$ conda create -p $(pwd)/demo nodejs=20.17.0
-p
: 使用 -p 参数在指定路径下创建 nodejs 执行环境
******
Downloading and Extracting Packages:
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate /home/myserver/demo/react/env/demo
#
# To deactivate an active environment, use
#
# $ conda deactivate
第三步: 激活安装的 nodejs 执行环境
$ conda activate /home/myserver/demo/react/env/demo/
(/home/myserver/demo/react/env/demo) myserver@my-dev:~/demo/react/env$
第四步: 验证安装结果
- npm 版本 【npm 参考笔记】
$ npm -v
10.8.2
- nodejs 版本 【nodejs 参考笔记】
$ node -v
v20.17.0
以上便是本文的全部内容,感谢您的阅读,如遇到任何问题,欢迎在评论区留言讨论。