Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nodejs not working, exec format error #8151

Open
1 of 2 tasks
wangqr opened this issue Mar 15, 2022 · 22 comments
Open
1 of 2 tasks

nodejs not working, exec format error #8151

wangqr opened this issue Mar 15, 2022 · 22 comments

Comments

@wangqr
Copy link

wangqr commented Mar 15, 2022

Version

Microsoft Windows [Version 10.0.19044.1586]

WSL Version

  • WSL 2
  • WSL 1

Kernel Version

4.4.0-19041-Microsoft

Distro Version

Arch

Other Software

No response

Repro Steps

Install nodejs from Archlinux repo with pacman -S nodejs, and run node

Expected Behavior

nodejs starts

Actual Behavior

nodejs does not start. exec format error.

wangqr@ocalhost:~$ node
zsh: exec format error: node

Diagnostic Logs

nodejs can start if we manually invoke ld-linux, although it is already the interpreter in the ELF.

wangqr@ocalhost:~$ /usr/bin/node
zsh: exec format error: /usr/bin/node
wangqr@ocalhost:~$ strace /usr/bin/node
execve("/usr/bin/node", ["/usr/bin/node"], 0x7ffff42aefa0 /* 25 vars */) = -1 ENOEXEC (Exec format error)
strace: exec: Exec format error
+++ exited with 1 +++
wangqr@ocalhost:~$ /lib/ld-linux-x86-64.so.2 /usr/bin/node
Welcome to Node.js v17.7.1.
Type ".help" for more information.
>
wangqr@ocalhost:~$ /lib64/ld-linux-x86-64.so.2 /usr/bin/node
Welcome to Node.js v17.7.1.
Type ".help" for more information.
>
wangqr@ocalhost:~$ file /usr/bin/node
/usr/bin/node: ELF 64-bit LSB pie executable, x86-64, version 1 (GNU/Linux), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=10ec67f51a763d04ac6e1fe305ce214fb40eabda, for GNU/Linux 4.4.0, stripped
wangqr@ocalhost:~$ readelf -h /usr/bin/node
ELF Header:
  Magic:   7f 45 4c 46 02 01 01 03 00 00 00 00 00 00 00 00
  Class:                             ELF64
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - GNU
  ABI Version:                       0
  Type:                              DYN (Position-Independent Executable file)
  Machine:                           Advanced Micro Devices X86-64
  Version:                           0x1
  Entry point address:               0x6aa570
  Start of program headers:          64 (bytes into file)
  Start of section headers:          34087608 (bytes into file)
  Flags:                             0x0
  Size of this header:               64 (bytes)
  Size of program headers:           56 (bytes)
  Number of program headers:         16
  Size of section headers:           64 (bytes)
  Number of section headers:         30
  Section header string table index: 29

@elsaco
Copy link

elsaco commented Mar 15, 2022

@wangqr what is the output of zsh --version?

This is a screenshot of Arch running node in a zsh session:

wsl_arch_node

@wangqr
Copy link
Author

wangqr commented Mar 15, 2022

It's zsh 5.8.1. Running under bash or strace gives save result though.

wangqr@ocalhost:~$ zsh --version
zsh 5.8.1 (x86_64-pc-linux-gnu)
wangqr@ocalhost:~$ bash -c /usr/bin/node
bash: line 1: /usr/bin/node: cannot execute binary file: Exec format error

@wangqr
Copy link
Author

wangqr commented Mar 15, 2022

Some more information:

  1. I do find a way to solve the issue:

    • In a docker, downgrade glibc from 2.35 to 2.33 using Archlinux Archive on 2022-02-14
    • Compile nodejs (asp checkout nodejs; cd nodejs/trunk; makepkg)
    • The resulting pkg.tar.zst will work fine on WSL1
    • Note: I built the package in a docker container running on a real archlinux machine. I haven't tried if downgrading glibc on WSL1 works. Because downgrading glibc is likely to break other packages, and fixing glibc issue in WSL1 is difficult.
  2. Compiling from source on WSL1 with the current glibc 2.35-2 will fail halfway with "Exec format error":

  g++ -o /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/mkcodecache -pthread -rdynamic -m64 -Wl,-z,noexecstack -Wl,--whole-archive /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/tools/v8_gypfiles/libv8_snapshot.a -Wl,--no-whole-archive -Wl,-z,relro -Wl,-z,now -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -Wl,--start-group /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/mkcodecache/src/node_snapshot_stub.o /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/mkcodecache/src/node_code_cache_stub.o /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/mkcodecache/tools/code_cache/mkcodecache.o /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/mkcodecache/tools/code_cache/cache_builder.o /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/libnode.a /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/deps/histogram/libhistogram.a /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/deps/uvwasi/libuvwasi.a /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/tools/v8_gypfiles/libv8_snapshot.a /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/tools/v8_gypfiles/libv8_libplatform.a /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/deps/llhttp/libllhttp.a /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/tools/v8_gypfiles/libv8_base_without_compiler.a /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/tools/v8_gypfiles/libv8_libbase.a /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/tools/v8_gypfiles/libv8_zlib.a /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/tools/v8_gypfiles/libv8_compiler.a /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/tools/v8_gypfiles/libv8_initializers.a -lz -luv -lbrotlidec -lbrotlienc -lcares -lnghttp2 -lcrypto -lssl -licui18n -licuuc -licudata -ldl -Wl,--end-group
  g++ -o /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/node_mksnapshot -pthread -rdynamic -m64 -Wl,-z,noexecstack -Wl,--whole-archive /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/tools/v8_gypfiles/libv8_snapshot.a -Wl,--no-whole-archive -Wl,-z,relro -Wl,-z,now -Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now -Wl,--start-group /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/node_mksnapshot/src/node_snapshot_stub.o /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/node_mksnapshot/src/node_code_cache_stub.o /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/node_mksnapshot/tools/snapshot/node_mksnapshot.o /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/libnode.a /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/deps/histogram/libhistogram.a /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/deps/uvwasi/libuvwasi.a /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/tools/v8_gypfiles/libv8_snapshot.a /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/tools/v8_gypfiles/libv8_libplatform.a /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/deps/llhttp/libllhttp.a /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/tools/v8_gypfiles/libv8_base_without_compiler.a /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/tools/v8_gypfiles/libv8_libbase.a /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/tools/v8_gypfiles/libv8_zlib.a /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/tools/v8_gypfiles/libv8_compiler.a /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj.target/tools/v8_gypfiles/libv8_initializers.a -lz -luv -lbrotlidec -lbrotlienc -lcares -lnghttp2 -lcrypto -lssl -licui18n -licuuc -licudata -ldl -Wl,--end-group
  LD_LIBRARY_PATH=/home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/lib.host:/home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/lib.target:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd ../.; mkdir -p /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj/gen; "/home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/mkcodecache" "/home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj/gen/node_code_cache.cc"
  LD_LIBRARY_PATH=/home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/lib.host:/home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/lib.target:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH; cd ../.; mkdir -p /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj/gen; "/home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/node_mksnapshot" "/home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj/gen/node_snapshot.cc"
/bin/sh: line 1: /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/mkcodecache: cannot execute binary file: Exec format error
make[1]: *** [node.target.mk:13: /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj/gen/node_code_cache.cc] Error 126
make[1]: *** Waiting for unfinished jobs....
/bin/sh: line 1: /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/node_mksnapshot: cannot execute binary file: Exec format error
make[1]: *** [node.target.mk:26: /home/wangqr/nodejs/trunk/src/node-17.7.1/out/Release/obj/gen/node_snapshot.cc] Error 126
rm 153bac10d83d38fd810d27369039858f690025da.intermediate 5fb9d05e8e7a809bf286a9a99430b12e50e12e34.intermediate 8c61239488171a14609c6ceaa1326c094866c228.intermediate 04b2e589442e78ea5b814ca0512cab45489617e8.intermediate
make: *** [Makefile:113: node] Error 2
==> ERROR: A failure occurred in build().
    Aborting...

@gavenkoa
Copy link

gavenkoa commented Mar 28, 2022

The same problem on Debian:

bash# apt-cache show nodejs
Package: nodejs
Version: 16.13.2+really14.19.1~dfsg-6
Installed-Size: 949
Maintainer: Debian Javascript Maintainers <pkg-javascript-devel@alioth-lists.debian.net>
Architecture: amd64
Replaces: libnode72 (<< 12.22.10~dfsg~), libnode83 (<< 16.13.2+really14.19.1~dfsg~), nodejs-legacy
Provides: node-types-node (= 14.18.12~16.13.2+really14.19.1~dfsg-6)
Depends: libc6 (>= 2.2.5), libnode83 (= 16.13.2+really14.19.1~dfsg-6)

When run:

/usr/bin/node --version
-bash: /usr/bin/node: cannot execute binary file: Exec format error

libc6 is v2.33-7.

bash# strace -f node --version
execve("/usr/bin/node", ["node", "--version"], 0x7fffdc8ab7e0 /* 30 vars */) = -1 ENOEXEC (Exec format error)
strace: exec: Exec format error
+++ exited with 1 +++

WSL 1:

uname -a
Linux msi 4.4.0-19041-Microsoft #1237-Microsoft Sat Sep 11 14:32:00 PST 2021 x86_64 GNU/Linux

@gavenkoa
Copy link

As in #5875 following succeeds:

/lib64/ld-linux-x86-64.so.2 /usr/bin/node --version
v14.19.1

@gavenkoa
Copy link

Similar symptoms in #5154

@qyb
Copy link

qyb commented Apr 22, 2022

the same error: #8219

@srogerf
Copy link

srogerf commented May 30, 2022

Had the same issues and upgrading to WSL 2 worked for me
wsl --set-version <name> 2

Use from
wsl -l -v

I did follow https://docs.microsoft.com/en-us/windows/wsl/install-manual#step-3---enable-virtual-machine-feature (and step 4) but node is working for me now. This is with Ubuntu 22.04

@gavenkoa
Copy link

gavenkoa commented Aug 3, 2022

Any progress? I upgraded to 21H2:

cmd /c ver
Microsoft Windows [Version 10.0.19044.1826]

but still happens:

# strace -f node --help
execve("/usr/bin/node", ["node", "--help"], 0x7ffff7a99db0 /* 31 vars */) = -1 ENOEXEC (Exec format error)
strace: exec: Exec format error
+++ exited with 1 +++

@gavenkoa
Copy link

gavenkoa commented Aug 3, 2022

As a workaround I updated npm tool (actual file is /usr/share/nodejs/npm/bin/npm-cli.js):

#!/lib64/ld-linux-x86-64.so.2 /usr/bin/node
//#!/usr/bin/env node
require('../lib/cli.js')(process)

@gavenkoa
Copy link

gavenkoa commented Aug 3, 2022

It is possible to make a workaround for node itself:

sudo mv /usr/bin/node /usr/bin/node-orig
printf '#!/bin/sh\nexec /lib64/ld-linux-x86-64.so.2 /usr/bin/node-orig "$@"' | sudo tee /usr/bin/node
sudo chmod a+x /usr/bin/node

My previous fix for npm won't work with the updated node executable, needs to be reverted.

@andreineculau
Copy link

@gavenkoa my general fix is to run

wsl-fix-exec-format-error $(realpath $(command -v node))

The script is here: https://github.com/ysoftwareab/yplatform/blob/master/bin/wsl-fix-exec-format-error

Based on https://gist.github.com/the-moog/179753aacc52b262d1068878d520e9c9 by @the-moog @wangqr 🙌

Running realpath is needed because sometimes (eg homebrew) node in your $PATH is a symlink

PS: I have found that I need to patch gzip as well, not just node, so a generic patch script is really good to have

@gavenkoa
Copy link

gavenkoa commented Aug 3, 2022

@andreineculau I understand the solution, the initial analysis was done by #8219 (comment) stating that it is a bug in lxcore.sys.

ls.so loads image like the exec call but avoids problems in Microsoft's lxcore.sys. It is better for sysadmins who are afraid binary patching with elftools.elf.elffile import ELFFile ))

@wangqr
Copy link
Author

wangqr commented Aug 4, 2022

sudo mv /usr/bin/node /usr/bin/node-orig
printf '#!/bin/sh\nexec /lib64/ld-linux-x86-64.so.2 /usr/bin/node-orig "$@"' | sudo tee /usr/bin/node
sudo chmod a+x /usr/bin/node

@gavenkoa This method can be problematic for modules that assume argv[0] be node itself when running node. For example, npm i node-sass will fail:

wangqr@ocalhost:~$ npm i node-sass
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm ERR! code 1
npm ERR! path /home/wangqr/node_modules/node-sass
npm ERR! command failed
npm ERR! command sh /tmp/postinstall-35c885a8.sh
npm ERR! Building: /usr/lib/ld-linux-x86-64.so.2 /home/wangqr/node_modules/node-sass/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! /home/wangqr/node_modules/node-sass/node_modules/node-gyp/bin/node-gyp.js: error while loading shared libraries: /home/wangqr/node_modules/node-sass/node_modules/node-gyp/bin/node-gyp.js: invalid ELF header
npm ERR! node-gyp not found!

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/wangqr/.npm/_logs/2022-08-04T10_51_18_640Z-debug-0.log

@gavenkoa
Copy link

gavenkoa commented Aug 4, 2022

@wangqr wrote:

For example, npm i node-sass will fail:

I had the same issue. I think you altered npm script, I warned about this above;

My previous fix for npm won't work with the updated node executable, needs to be reverted.

If node executable is operable every tool is Nodejs toolchain will wok.

@qchencc
Copy link

qchencc commented Sep 4, 2022

I got the same problem.
Win10 21H2 and Ubuntu 22.04 WSL1

after sudo apt install nodejs
only get /usr/bin/node: cannot execute binary file: Exec format error

I fixed this problem by using nodejs package
https://github.com/nodesource/distributions/blob/master/README.md#debinstall

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

@lexavey
Copy link

lexavey commented Sep 10, 2022

i got same problem.

i fix this problem using this command, hope help other

wget https://gist.githubusercontent.com/lexavey/155a95d803224d7c0af7e225d0d82396/raw/3b4c103e4c3ff702674f96dd12cc412e9c8766ad/fixexec.py
sudo python3 ./fixexec.py $(realpath $(command -v node))
node -v

@PovelikinRostislav
Copy link

Update to WSL v2 as @srogerf suggested - worked for me.
Ubuntu 22.04.1
Node v12.22.9

@justonia
Copy link

@qchencc 's solution worked for me on WSL1 + Ubuntu 18.04 + Windows 11 22H2, but required switching to Node v16:

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

@ytrezq
Copy link

ytrezq commented Nov 21, 2022

There were a similar issue with Qt. It was fixable using a strip command for removing .note section from the binary. But which one it would be in that case?

@vlatkodimeski
Copy link

root@GM00234:/mnt/c/api-service-js# sudo apt-get install -y nodejs
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
adwaita-icon-theme at-spi2-core fontconfig gtk-update-icon-cache gyp hicolor-icon-theme humanity-icon-theme javascript-common libatk-bridge2.0-0 libatk1.0-0 libatk1.0-data libatspi2.0-0 libauthen-sasl-perl libc-ares2 libcairo-gobject2
libcairo2 libclone-perl libcolord2 libcups2 libdata-dump-perl libdatrie1 libdrm-amdgpu1 libdrm-intel1 libdrm-nouveau2 libdrm-radeon1 libencode-locale-perl libepoxy0 libfile-basedir-perl libfile-desktopentry-perl libfile-listing-perl
libfile-mimeinfo-perl libfont-afm-perl libfontenc1 libgdk-pixbuf-2.0-0 libgdk-pixbuf2.0-bin libgdk-pixbuf2.0-common libgl1 libgl1-amber-dri libgl1-mesa-dri libglapi-mesa libglvnd0 libglx-mesa0 libglx0 libgraphite2-3 libgtk-3-0
libgtk-3-bin libgtk-3-common libgtkd-3-0 libharfbuzz0b libhtml-form-perl libhtml-format-perl libhtml-parser-perl libhtml-tagset-perl libhtml-tree-perl libhttp-cookies-perl libhttp-daemon-perl libhttp-date-perl libhttp-message-perl
libhttp-negotiate-perl libice6 libio-html-perl libio-socket-ssl-perl libio-stringy-perl libipc-system-simple-perl libjs-events libjs-highlight.js libjs-inherits libjs-is-typedarray libjs-psl libjs-source-map libjs-sprintf-js
libjs-typedarray-to-buffer liblcms2-2 libllvm11 libllvm13 liblwp-mediatypes-perl liblwp-protocol-https-perl libmailtools-perl libnet-dbus-perl libnet-http-perl libnet-smtp-ssl-perl libnet-ssleay-perl libnode-dev libnode72 libnotify-bin
libnotify4 libpango-1.0-0 libpangocairo-1.0-0 libpangoft2-1.0-0 libpciaccess0 libphobos2-ldc-shared98 libpixman-1-0 librsvg2-2 librsvg2-common libsensors-config libsensors5 libsm6 libssl-dev libthai-data libthai0 libtie-ixhash-perl
libtimedate-perl libtry-tiny-perl liburi-perl libuv1-dev libvte-2.91-0 libvte-2.91-common libvted-3-0 libvulkan1 libwayland-client0 libwayland-cursor0 libwayland-egl1 libwww-perl libwww-robotrules-perl libx11-protocol-perl libx11-xcb1
libxaw7 libxcb-dri2-0 libxcb-dri3-0 libxcb-glx0 libxcb-present0 libxcb-randr0 libxcb-render0 libxcb-shape0 libxcb-shm0 libxcb-sync1 libxcb-xfixes0 libxcomposite1 libxcursor1 libxdamage1 libxfixes3 libxft2 libxi6 libxinerama1
libxkbcommon0 libxkbfile1 libxml-parser-perl libxml-twig-perl libxml-xpathengine-perl libxmu6 libxrandr2 libxrender1 libxshmfence1 libxt6 libxtst6 libxv1 libxxf86dga1 libxxf86vm1 mesa-vulkan-drivers node-abab node-abbrev node-agent-base
node-ansi-regex node-ansi-styles node-ansistyles node-aproba node-archy node-are-we-there-yet node-argparse node-arrify node-asap node-asynckit node-balanced-match node-brace-expansion node-builtins node-chalk node-chownr
node-clean-yaml-object node-cli-table node-clone node-color-convert node-color-name node-colors node-columnify node-combined-stream node-commander node-console-control-strings node-core-util-is node-cssom node-cssstyle node-debug
node-decompress-response node-defaults node-delayed-stream node-delegates node-depd node-diff node-encoding node-end-of-stream node-err-code node-escape-string-regexp node-events node-fancy-log node-foreground-child
node-fs-write-stream-atomic node-fs.realpath node-function-bind node-gauge node-get-stream node-glob node-got node-graceful-fs node-growl node-has-flag node-has-unicode node-hosted-git-info node-https-proxy-agent node-iconv-lite
node-iferr node-imurmurhash node-indent-string node-inflight node-inherits node-ini node-ip node-ip-regex node-is-buffer node-is-plain-obj node-is-typedarray node-isarray node-isexe node-json-buffer node-json-parse-better-errors
node-jsonparse node-kind-of node-lcov-parse node-lodash-packages node-log-driver node-lowercase-keys node-lru-cache node-mimic-response node-minimatch node-minimist node-minipass node-ms node-mute-stream node-negotiator
node-normalize-package-data node-npm-bundled node-npm-package-arg node-npmlog node-object-assign node-once node-osenv node-p-cancelable node-p-map node-path-is-absolute node-process-nextick-args node-promise-inflight node-promise-retry
node-promzard node-psl node-pump node-punycode node-quick-lru node-read node-read-package-json node-readable-stream node-resolve node-retry node-rimraf node-run-queue node-safe-buffer node-semver node-set-blocking node-signal-exit
node-slash node-slice-ansi node-source-map node-source-map-support node-spdx-correct node-spdx-exceptions node-spdx-expression-parse node-spdx-license-ids node-sprintf-js node-ssri node-stack-utils node-stealthy-require
node-string-decoder node-string-width node-strip-ansi node-supports-color node-text-table node-time-stamp node-tmatch node-tough-cookie node-typedarray-to-buffer node-unique-filename node-universalify node-util-deprecate
node-validate-npm-package-license node-validate-npm-package-name node-wcwidth.js node-webidl-conversions node-whatwg-fetch node-wide-align node-wrappy node-write-file-atomic node-yallist perl-openssl-defaults tilix tilix-common
ubuntu-mono x11-common x11-utils x11-xserver-utils xdg-utils
Use 'sudo apt autoremove' to remove them.
The following packages will be upgraded:
nodejs
1 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 27.2 MB of archives.
After this operation, 128 MB of additional disk space will be used.
Get:1 https://deb.nodesource.com/node_16.x jammy/main amd64 nodejs amd64 16.19.0-deb-1nodesource1 [27.2 MB]
Fetched 27.2 MB in 3s (9991 kB/s)
(Reading database ... 51521 files and directories currently installed.)
Preparing to unpack .../nodejs_16.19.0-deb-1nodesource1_amd64.deb ...
Unpacking nodejs (16.19.0-deb-1nodesource1) over (12.22.9dfsg-1ubuntu3) ...
dpkg: error processing archive /var/cache/apt/archives/nodejs_16.19.0-deb-1nodesource1_amd64.deb (--unpack):
trying to overwrite '/usr/include/node/common.gypi', which is also in package libnode-dev 12.22.9
dfsg-1ubuntu3
dpkg-deb: error: paste subprocess was killed by signal (Broken pipe)
Errors were encountered while processing:
/var/cache/apt/archives/nodejs_16.19.0-deb-1nodesource1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@GM00234:/mnt/c/api-service-js# node -v
bash: /usr/bin/node: cannot execute binary file: Exec format error
root@GM00234:/mnt/c/api-service-js#

Any solution for this?

Nebucatnetzer pushed a commit to Nebucatnetzer/nixos that referenced this issue Mar 21, 2023
Otherwise I get the error message as described here:
microsoft/WSL#8151
@ZenCodeXY
Copy link

I also encountered the same problem and solved it by:

  1. Download the Linux Binary file package from Nodejs official website (https://nodejs.org/en/download) and decompress it;
  2. Establish a soft connection for node/npm/npx;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests