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

Can not work on Windows #992

Closed
MountainAndMorning opened this issue Jun 7, 2023 · 4 comments
Closed

Can not work on Windows #992

MountainAndMorning opened this issue Jun 7, 2023 · 4 comments

Comments

@MountainAndMorning
Copy link

I followed the hello world example on Windows 10.
node -v
v18.16.0
npm -v
9.5.1

npm init neon cpu-count

cd cpu-count
npm install

node
require('.')

But got the error below:

(base) C:\Users\iridium\Documents\cpu-count>node
Welcome to Node.js v18.16.0.
Type ".help" for more information.

req
Request require

require('.')
Uncaught:
Error: \?\C:\Users\iridium\Documents\cpu-count\index.node is not a valid Win32 application.
\?\C:\Users\iridium\Documents\cpu-count\index.node
at Module._extensions..node (node:internal/modules/cjs/loader:1338:18)
at Module.load (node:internal/modules/cjs/loader:1117:32)
at Module._load (node:internal/modules/cjs/loader:958:12)
at Module.require (node:internal/modules/cjs/loader:1141:19)
at require (node:internal/modules/cjs/helpers:110:18) {
code: 'ERR_DLOPEN_FAILED'
}

I also try use the node-v14.16.0-x64 and the node-v16.13.0-x64 and also failed.

@kjvalencik
Copy link
Member

kjvalencik commented Jun 7, 2023

What version of Windows? What CPU architecture? Can you double check your default cargo target (rustup default)?

It seems like the module isn't targeting Windows.

@MountainAndMorning
Copy link
Author

Thanks for your help.
Windows 10 version 21H2
AMD Ryzen Threadripper 3970X 32-Core
I solved the problem by deleting the rust installed by the rust-1.70,0-i686-pc-windows-gpu installer and reinstall the rust by the rustup-init installer.

@jdms754
Copy link

jdms754 commented Aug 8, 2024

Running into the same error. I am able to build and run another rust executable successfully.

Error: \\?\C:\Users\korolev\cpu-count\index.node is not a valid Win32 application.
\\?\C:\Users\korolev\cpu-count\index.node
    at Module._extensions..node (node:internal/modules/cjs/loader:1340:18)
    at Module.load (node:internal/modules/cjs/loader:1119:32)
    at Module._load (node:internal/modules/cjs/loader:960:12)
    at Module.require (node:internal/modules/cjs/loader:1143:19)
    at require (node:internal/modules/cjs/helpers:110:18) {
  code: 'ERR_DLOPEN_FAILED'
}

rustup show returns

PS C:\Users\korolev\cpu-count> rustup show
Default host: aarch64-pc-windows-msvc
rustup home:  C:\Users\korolev\.rustup

stable-aarch64-pc-windows-msvc (default)
rustc 1.80.1 (3f5fd8dd4 2024-08-06)

Running Windows 11 Pro on Parallels (Apple Silicon 3.20 GHz (6 processors)) with Node v18.16.1 x64

edit: switching rustup default toolchain to stable-x86_64-pc-windows-msvc seems to fix the issue

@kjvalencik
Copy link
Member

@jdms754 That seems sounds like x86 Windows is being run and not ARM. This would be expected.

FYI, Neon does not do any special building. A Node native addon is a standard C-dynamic library (cdylib in Rust). Node loads the shared library with dlopen like the OS would for any other shared library and looks for a symbol (function) with the name napi_register_module_v1. That's what #[neon::main] generates.

I'm going to close this issue since it's highly likely any similar issues are related to misconfigured Rust toolchain and not Neon.

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

3 participants