赶知识网

运行npm“/usr/bin/node时出错:1:ELF:未找到”

2023-12-28 / 395次点击 Js/Css/jQuery npm

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:

  1. Remove any existing installations of Node.js or npm
    $ sudo apt remove npm
    
  2. Install cURL and nvm
    $ sudo apt-get install curl
    $ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/master/install.sh | bash
    
  3. Close your current terminal, reopen it, and install Node
    $ nvm install --lts
    

Source: Set up Node.js on WSL 2 | Microsoft Learn

Top10

沪ICP备09053415号 © 赶知识网