Operating System:Ubuntu 18.04.6 LTS
Kernel:Linux 4.15.0-169-generic
Architecture:x86-64
- Ubuntu 18.04 安装Node.js 18.x 后报错:
1
2
|
root@ubuntu:~# node -v
node: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.28' not found (required by node)
|
因为 Ubuntu18.04 默认的 glibc 版本为 2.27
1
2
|
root@ubuntu:~# ldd --version
Copyright (C) 2018 Free Software Foundation, Inc.
|
1
2
3
|
root@ubuntu:~# sudo apt remove nodejs
root@ubuntu:~# sudo apt remove npm
root@ubuntu:~# sudo apt autoremove
|
删除 /usr/local/lib、/usr/local/include 和 /usr/local/bin 下所有 node 和 node_modules 文件
1
2
|
root@ubuntu:~# curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
root@ubuntu:~# sudo apt-get install -y nodejs
|
1
2
3
4
5
6
|
root@ubuntu:~# node -v
v16.18.1
root@ubuntu:~# npm -v
8.19.2
root@ubuntu:~# npx -v
8.19.2
|
1
2
3
4
5
6
|
root@ubuntu:~# curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
ok
root@ubuntu:~# echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
deb https://dl.yarnpkg.com/debian/ stable main
root@ubuntu:~# apt update
root@ubuntu:~# apt install yarn
|
1
2
|
root@ubuntu:~# yarn --version
1.22.19
|
1
2
|
root@ubuntu:~# yarn config get registry
https://registry.yarnpkg.com
|
1
2
3
4
|
root@ubuntu:~# yarn config set registry 'https://registry.npm.taobao.org'
yarn config v1.22.19
success Set "registry" to "https://registry.npm.taobao.org".
Done in 0.02s.
|