i got error when running npm, i’ve allready try to reinstall with
sudo apt-get remove nodejs npm -y && sudo apt-get install nodejs npm -y
this problem still exist
/usr/bin/node: 1: ELF: not found
/usr/bin/node: 2: : not found
/usr/bin/node: 4: Syntax error: Unterminated quoted string
im using Ubuntu WSL
Distributor ID: Ubuntu
Description: Ubuntu 22.04.1 LTS
Release: 22.04
Codename: jammy
Linux localhost 4.4.0-19041-Microsoft #1237-Microsoft Sat Sep 11 14:32:00 PST 2021 x86_64 x86_64 x86_64 GNU/Linux
npm -v command
npm -v
-bash: /usr/bin/node: cannot execute binary file: Exec format error
4
Answers
i found same problem in github
https://github.com/microsoft/WSL/issues/8151
then i fix this problem with
hope help other with same problem
I could not get the solution to work, which was given here.
A different solution propossed from the same source which itself linked to here worked for me:
I first removed node and npm completly (To be precise all packages with the name in it, but I am not sure this is necessary). Then I used the give install command:
This is for Ubuntu and node version 18, but you can find other operating systems and versions as well (look here).
I hope this helps someone.
Seems like an issue with WSL Ubuntu 22 Jammy and 8.5.1 package.
You may have luck installing a different package version, but I had issues with this.
Installed WSL Ubuntu 20 with 6.14.4, issue was gone.
This was an issue for me on Windows 10, using WSL2 and Ubuntu 22.04 LTS. The other solutions in this post did not help, and I was unwilling to downgrade to Ubuntu 20. Instead, I managed to fix it by removing all node-related packages with apt and then installing node via nvm as per this guide by Microsoft.
So to remove the packages:
Then install nvm…
Restart the terminal. Then, make sure nvm is installed:
Finally, use nvm to install the latest version of node and npm:
Check to make sure node and npm are installed:
Hope this helps!