我们可以使用asdf

对于已经从使用nodenv转变为使用anyenv的各位,现在大概是时候试试Deno了吧。在使用anyenv的时候,如果你思考着在anyenv中安装deno,并且运行了$ anyenv install -l,却发现没有denoenv存在,会不会感到有些烦恼呢?不过,asdf就有这个功能!

因此,我尝试使用asdf。

请问asdf?

nodenv是一个可以切换node版本的工具。它可以帮助我们切换环境变量,非常方便在多个项目之间切换。anyenv和asdf不仅可以管理node的版本,还可以管理其他语言的版本。

    • anyenv, asdf で言語をローカルにインストールできる。

 

    • 同一言語でも複数バージョン入れておける。

 

    プロジェクトディレクトリに.xxxversionのファイルを置いておくことで勝手に切り替えてくれる。

安装

这边,很简单。
https://asdf-vm.com/#/core-manage-asdf

请务必不要忘记在~/.bashrc等文件中进行追加。

使用命令

不是太常见。插件等于编程语言。 . Chā .)

列出所有支持的语言列表的($ asdf plugin list all)命令。

有很多。

$ asdf插件添加安裝語言

例如,用中文将以下句子改写:
「将asdf插件添加为nodejs」

列出所有的语言版本清单

0.1.14
0.1.15
0.1.16
~~snip;

使用asdf安装特定版本的

顺便提一下,在安装nodejs时需要事先设置PGP密钥以便验证文件的校验和。 https://github.com/asdf-vm/asdf-nodejs

[derori@murata ~]$ asdf install nodejs 15.8.0
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3811    0  3811    0     0  90738      0 --:--:-- --:--:-- --:--:-- 90738
Authenticity of checksum file can not be assured! Please be sure to check the README of asdf-nodejs in case you did not yet import the needed PGP keys. If you already did that then that is the point to become SUSPICIOUS! There must be a reason why this is failing. If you are installing an older NodeJS version you might need to import OpenPGP keys of previous release managers. Exiting.

[derori@murata ~]$ bash -c '${ASDF_DATA_DIR:=$HOME/.asdf}/plugins/nodejs/bin/import-release-team-keyring'
gpg: /home/derori/.gnupg/trustdb.gpg: trustdb created
gpg: key D7062848A1AB005C: public key "Beth Griggs <bgriggs@redhat.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1
gpg: key 7434390BDBE9B9C5: public key "Colin Ihrig <cjihrig@gmail.com>" imported

~~snip;


[derori@murata ~]$ asdf install nodejs 15.8.0
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  3811    0  3811    0     0  82847      0 --:--:-- --:--:-- --:--:-- 84688
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 31.1M  100 31.1M    0     0  79.7M      0 --:--:-- --:--:-- --:--:-- 79.7M
node-v15.8.0-linux-x64.tar.gz: OK
[derori@murata ~]$ asdf list nodejs
  15.8.0

使用指定版本的asdf [全局|本地] <名称> <版本>

全局: 整个用户
本地: 在该目录下

可以创建并管理一个名为 .tool-versions 的文件。就像 .node-versions 一样,可以提交它。

$ asdf 更新

给它更新一下吧。

总结

因为与anyenv共存会变得混乱,所以只能选择其中一个,但是我想使用asdf来创建一个新的环境!!!!

如果在`$HOME/.asdfrc`文件中写入`legacy_version_file = yes`,ASDF将能够查看像`.node-versions`等文件。详见https://asdf-vm.com/#/core-configuration?id=homeasdfrc。

啊。deno的话,你只需要执行 $ asdf plugin add deno && asdf install deno latest 就可以了,没问题的。

文档
https://asdf-vm.com/#/core-manage-asdf

bannerAds