gpt4 book ai didi

node.js - 无法使用 nvm 或 apt get install (wsl2 ubuntu) 安装 node/npm

转载 作者:行者123 更新时间:2023-12-04 19:24:14 28 4
gpt4 key购买 nike

我无法使用 nvm 或 apt get install (wsl2 ubuntu) 安装 node/npm。这是我首先尝试的

$ code export NVM_NODEJS_ORG_MIRROR=http://nodejs.org/dist 
$ curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash
它安装了 nvm 但当我安装了 nvm ls我只得到了这个(没有列出版本)
->       system
iojs -> N/A (default)
node -> stable (-> N/A) (default)
unstable -> N/A (default)
所以我做了 ~/.nvm并尝试了 apt-get install -y nodejs这似乎工作......
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Suggested packages:
npm
The following NEW packages will be installed:
nodejs
0 upgraded, 1 newly installed, 0 to remove and 8 not upgraded.
Need to get 0 B/122 kB of archives.
After this operation, 932 kB of additional disk space will be used.
Selecting previously unselected package nodejs.
(Reading database ... 40014 files and directories currently installed.)
Preparing to unpack .../nodejs_12.22.9~dfsg-1ubuntu3_amd64.deb ...
Unpacking nodejs (12.22.9~dfsg-1ubuntu3) ...
Setting up nodejs (12.22.9~dfsg-1ubuntu3) ...
update-alternatives: using /usr/bin/nodejs to provide /usr/bin/js (js) in auto mode
Processing triggers for man-db (2.10.2-1) ...
Scanning processes...
Scanning candidates...
Scanning processor microcode...
Scanning linux images...

Failed to retrieve available kernel versions.

Failed to check for processor microcode upgrades.

No services need to be restarted.

No containers need to be restarted.

User sessions running outdated binaries:
root @ /dev/pts/0: bash[9754,9845], sh[10875]
root @ /dev/tty1: init[9752], wsltermd[9753]
root @ /dev/tty2: bash[25], init[24]

No VM guests are running outdated hypervisor (qemu) binaries on this host.
然后我做了 node -v ...
bash: /usr/bin/node: cannot execute binary file: Exec format error
我正在一台带有win10 home的全新Windows机器上运行。我安装了 wsl2/ubuntu-22.04 并且一直在使用它没有问题。所以一切都是新鲜的。我不支持任何代理。
我正在拔头发。有人能帮我吗?
编辑:我做了 apt install nodejs npm从 vscode wsl 终端并进行了很长时间的安装,似乎很成功。现在当我运行 npm i -g vite我得到...
/usr/bin/node: 1: ELF: not found
/usr/bin/node: 2: : not found
/usr/bin/node: 4: Syntax error: Unterminated quoted string
所以我失去了更多的头发。顺便说一句,我一直在遵循 IT Crowd 的建议并经常重启。

最佳答案

我通过恢复到 ubuntu 18.04、安装 nvm 并执行 nvm install 'lts/*' 安装了 node/npm .nvm ls仍然没有给出任何结果,所以我很惊讶安装成功了。无法列出 Node 版本也是一种痛苦。

关于node.js - 无法使用 nvm 或 apt get install (wsl2 ubuntu) 安装 node/npm,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72610244/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com