How to use node in wsl - zsh: exec format error: node

Viewed 67

I am using windows 10 linux subsystem - linux 20.04. I have installed brew and using zsh (downloaded with brew).

The problem is when i have downloaded node with brew as well it does not work and shows me the following error:

zsh: exec format error: node

And when i am typing npm:

/home/linuxbrew/.linuxbrew/bin/node: 1: 0�: not found
/home/linuxbrew/.linuxbrew/bin/node: 1: �: not found
/home/linuxbrew/.linuxbrew/bin/node: 1: ����: not found
/home/linuxbrew/.linuxbrew/bin/node: 1: ʌ�,�/W�%r��@�:,2�F�: not found
/home/linuxbrew/.linuxbrew/bin/node: 1: ELF: not found
/home/linuxbrew/.linuxbrew/bin/node: 1:R�td0�0�E0�E�K�KP�P�EP�E: not found
/home/linuxbrew/.linuxbrew/bin/node: 2: K�/�q: not found
/home/linuxbrew/.linuxbrew/bin/node: 1: 
                                         �
: not found                               �0�0�E0�E�O�
/home/linuxbrew/.linuxbrew/bin/node: 10: Syntax error: ")" unexpected

Thanks for any kind of help :)

1 Answers

Please see this bug on the WSL github. There currently appear to be two solutions either upgrade to WSL2 or grab the package from nodesource as per this comment from two days ago.

curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs

Exec format error means that the binary for the wrong architecture is being installed - you could try using NVM to install Node - brew and WSL I can't say I've ever used but it wouldn't be my goto solution.

Related