nodejs: Unable to run Next.js apps
Description / Steps to reproduce the issue
Hi! I am using the mingw-w64-nodejs package for Node.js development. Unfortunately, I can't run the development servers for my Next.js apps. I believe this is a bug because the apps run fine when I use my system's Node.js, but they don't run when I use the MSYS2 version. For both versions, node --version returns v18.16.1.
Here are some steps to recreate the issue I am experiencing:
- Create a Next.js app by running this command:
npx create-next-app@latest next-app - Press Enter several times to install
create-next-appand select the default options - Change into the directory:
cd next-app - Run the development server:
npm run dev
(You can then run npm uninstall -g create-next-app to uninstall the create-next-app tool.)
Expected behavior
I expected the command npm run dev to run the development server at http://localhost:3000 and produce output similar to that produced by my system's Node.js.
The output should look something like this:
> [email protected] dev
> next dev
- ready started server on 0.0.0.0:3000, url: http://localhost:3000
- event compiled client and server successfully in 671 ms (20 modules)
- wait compiling...
- event compiled client and server successfully in 375 ms (20 modules)
- wait compiling /page (client and server)...
- event compiled client and server successfully in 16.7s (486 modules)
Actual behavior
Running npm run dev produces the following output:
> [email protected] dev
> next dev
- ready started server on 0.0.0.0:3000, url: http://localhost:3000
thread '<unnamed>' panicked at 'Must load N-API bindings', C:\Users\runneradmin\.cargo\registry\src\
index.crates.io-6f17d22bba15001f\napi-sys-2.2.3\src\functions.rs:7:3
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
The server does not run.
Verification
- [X] I have verified that my MSYS2 is up-to-date before submitting the report (see https://www.msys2.org/docs/updating/)
Windows Version
MINGW64_NT-10.0-19045
MINGW environments affected
- [ ] MINGW64
- [ ] MINGW32
- [x] UCRT64
- [ ] CLANG64
- [ ] CLANG32
- [ ] CLANGARM64
Are you willing to submit a PR?
I would love to contribute, but I don't know how to fix the issue.
do you have rust package installed?
Hi @raedrizqie 😄 I just installed the mingw-w64-rust package and tried running the commands again. Sadly, the same output occurred. 😞 I didn't have the Rust package before.
i think it is because rust binding is not enabled on nodejs
that does sound likely.
Would this be an issue on my end, or would it be an issue with the build configuration of the package?
this is a problem with the configuration on this end but you have to understand getting nodejs to build and work with mingw-w64 was quite an undertaking in itself, i just think it sorta went in to the TODO section at some point :). we can try enabling it but there is no guarantee it will work out of the box, a good deal of the nodejs functionality was only recently fixed.
looks like N-API is not an official part of nodejs and might need to be ported first, nodejs itself has no rust bindings.
I'm looking into this. I'll post updates/ask questions here when there's progress.
@revelator At first glance, I'm having trouble understanding what would need to be ported in order for this to happen. (I'm comparing with what arch does in the hope to find what we are missing here.) Could you point me somewhere to start looking?
been a while since i looked at anything due to health problems. i dont think the problem is located in our nodejs package itself, it might just be the N-api package that needs some adjustment but i cant find that one in the arch repository so im not sure they ever ported it ?.
ah it was renamed Node-API and it is a part of nodejs now... hmm gotta find out where in it things go wrong then.
Ah I see. That makes sense! I hope you feel better now! Anyway, please let me know if there's anything I can help with!
sadly no, i broke my back in two places around 15 years ago now, it took them 10 years to figure out it was broken though and in the meantime my nerve connections got all messed up. So i have two metal implants + 8 large screws in my back now :S and there has been some complications. Ill see if i can figure somehing out but it might take a while cause i cant sit for very long anymore.
there is an option enable_rust or simething like that, when building nodejs.. but i dont know if it will make any difference at all.. i will try it later
sadly no, i broke my back in two places around 15 years ago now, it took them 10 years to figure out it was broken though and in the meantime my nerve connections got all messed up. So i have two metal implants + 8 large screws in my back now :S and there has been some complications. Ill see if i can figure somehing out but it might take a while cause i cant sit for very long anymore.
I'm sorry to hear that. Please, do prioritize your health above all things.
i will though ive not much choice in the matter anyway :) but if i have a good day ill see if i can figure something out.
@gnpivo i think we need to compile nextjs from source.. do you know what are the steps?
if we use npx, it will download the prebuilt node module of swc.win32-x64-msvc.node and try to use it, which is not compatible for mingw env..
so, imo, either you ask them to provide swc.win32-x64-gnu.node or you must compile your own
yeah it would need portage the msvc model will not work with mingw-w64. might not be a big problem creating a port so asking them would make sense.
they could use our patchset for nodejs as a template i believe, that might make things easier for them.