asdf - node.모든 js 디렉터리의 버전 관리

7557 단어 HomebrewasdfMacOStech
컴퓨터도 변화가 있어서 복습하기 어렵다.
옛 환경이지만 환경을 검증할 준비가 되지 않아 PC에 환경을 구축해 보자.

전제 조건


macOS


% sw_vers
ProductName:	macOS
ProductVersion:	12.2.1

Homebrew


% brew -v
Homebrew 3.4.1
Homebrew/homebrew-core (git revision 7f1b3091246; last commit 2022-03-14)
Homebrew/homebrew-cask (git revision 96b4f7dabd; last commit 2022-03-14)

저널


설치하다.


# (私の場合)必要なパッケージをインストール
# 最後の「coreutils」「curl」「git」くらいでも十分
% brew install coreutils automake autoconf openssl libyaml readline libxslt libtool unixodbc unzip curl coreutils curl git

# 本体インストール
% brew install asdf

# PATH更新 ※ zshを使用しています。
% echo -e "\n. $(brew --prefix asdf)/asdf.sh" >> ~/.zshrc
% source ~/.zshrc

# 動作確認
% asdf plugin list all

버전 관리


# バージョン管理用のファイル設置
% cd ~/hoge/v1
% vi .tool-versions
% cat .tool-versions
nodejs lts-fermium

# asdfでのバージョン確認
% asdf current
nodejs          lts-fermium     Not installed. Run "asdf install nodejs lts-fermium"

# asdfでのインストールがまだなので、インストールしてあげる(結構時間かかります)
% asdf install nodejs lts-fermium
Installing alias lts-fermium as 14.19.0
Cloning node-build...
Downloading node-v14.19.0.tar.gz...
-> https://nodejs.org/dist/v14.19.0/node-v14.19.0.tar.gz

WARNING: node-v14.19.0 is in LTS Maintenance mode and nearing its end of life.
It only receives *critical* security updates, *critical* bug fixes and documentation updates.

Installing node-v14.19.0...
Installed node-v14.19.0 to /Users/hogefuga/.asdf/installs/nodejs/14.19.0

Linking "lts-fermium" to "14.19.0"

# バージョン確認
% asdf current                   
nodejs          lts-fermium     /Users/hogefuga/iv_site/v2.0/.tool-versions
% node -v                        
v14.19.0

보충: M1 패키지가 아닌 경우


바로 이거예요.🙃

나쁜 놈


% asdf install nodejs 13.2.0
Trying to update node-build... ok
Downloading node-v13.2.0.tar.gz...
-> https://nodejs.org/dist/v13.2.0/node-v13.2.0.tar.gz

WARNING: node-v13.2.0 is in LTS Maintenance mode and nearing its end of life.
It only receives *critical* security updates, *critical* bug fixes and documentation updates.

Installing node-v13.2.0...

BUILD FAILED (OS X 12.2.1 using node-build 4.9.70-5-gb9c8f04d)

Inspect or clean up the working tree at /var/folders/_d/q_4n0_qn66jggblwgty9qb000000gn/T/node-build.20220314122022.45853.kN6Imm
Results logged to /var/folders/_d/q_4n0_qn66jggblwgty9qb000000gn/T/node-build.20220314122022.45853.log

Last 10 log lines:
^
../deps/openssl/config/archs/linux-x86_64/asm_avx2/crypto/aes/aesni-sha1-x86_64.s:2731:8: error: invalid alignment value
.align 32
       ^
../deps/openssl/config/archs/linux-x86_64/asm_avx2/crypto/aes/aesni-sha1-x86_64.s:3031:1: error: unknown directive
.size aesni_cbc_sha1_enc_shaext,.-aesni_cbc_sha1_enc_shaext
^
make[1]: *** [/private/var/folders/_d/q_4n0_qn66jggblwgty9qb000000gn/T/node-build.20220314122022.45853.kN6Imm/node-v13.2.0/out/Release/obj.target/openssl/deps/openssl/config/archs/linux-x86_64/asm_avx2/crypto/aes/aesni-sha1-x86_64.o] Error 1
rm d7a05ecdf626c18372eb32e377c5c9372dae8527.intermediate
make: *** [node] Error 2

대책


이것도 Docker 때와 마찬가지로 구조가 지정된 상태에서 실행해야 한다.다음은 참고 문헌이다.
https://github.com/asdf-vm/asdf-nodejs/issues/189#issuecomment-757048599
% arch -x86_64 asdf install nodejs 13.2.0
Trying to update node-build... ok
Downloading node-v13.2.0-darwin-x64.tar.gz...
-> https://nodejs.org/dist/v13.2.0/node-v13.2.0-darwin-x64.tar.gz

WARNING: node-v13.2.0-darwin-x64 is in LTS Maintenance mode and nearing its end of life.
It only receives *critical* security updates, *critical* bug fixes and documentation updates.

Installing node-v13.2.0-darwin-x64...
Installed node-v13.2.0-darwin-x64 to /Users/hogefuga/.asdf/installs/nodejs/13.2.0
할 수 있어!

설치 후 명령도 주의해야 한다


M1에서 이전 환경을 사용할 때는 지정된 상태에서 구조를 실행해야 합니다.
% arch -x86_64 npm install
그럼에도 불구하고 버전 관리는 간단하고 수월해졌다.

좋은 웹페이지 즐겨찾기