运行npm“/usr/bin/node时出错:1:ELF:未找到”
Whenever i try to use nmp (npm / npm install / sudo npm install / etc
) it output this:
/usr/bin/node: 1: ELF: not found
/usr/bin/node: 2: : not found
/usr/bin/node: 4: Syntax error: Unterminated quoted string
I tried to reinstall it with sudo apt reinstall npm
and sudo apt autoremove npm
sudo apt install npm
but result is the same.
If it is important apt
output this at the end of reinstalling
Failed to check for processor microcode upgrades.
No services need to be restarted.
No containers need to be restarted.
User sessions running outdated binaries:
myname @ /dev/tty1: bash[12777]
root @ /dev/pts/0: apt[13552,13666], sh[13671]
root @ /dev/tty1: init[12776]
No VM guests are running outdated hypervisor (qemu) binaries on this host.
I use Ubuntu 22.04.1 LTS from Microsoft Store
The version of Node that can be installed with Ubuntu's apt-get
command in WSL is currently outdated. These commands worked for me:
- Remove any existing installations of Node.js or npm
$ sudo apt remove npm
- Install cURL and nvm
$ sudo apt-get install curl
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
- Close your current terminal, reopen it, and install Node
$ nvm install --lts
Source: Set up Node.js on WSL 2 | Microsoft Learn
有话要说