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

zeromq works standalone but not when used within Next.js: "No native build was found for ..." #61844

Closed
eulersson opened this issue Feb 9, 2024 · 3 comments · Fixed by #62019 or #62105
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. locked

Comments

@eulersson
Copy link

eulersson commented Feb 9, 2024

Link to the code that reproduces this issue

https://github.com/eulersson/zeromq.js-next.js-errors

To Reproduce

Manually

Basically create a next app npx create-next-app@latest with all the defaults, install
zeromq npm install zeromq@6.0.0-beta.19, import it anywhere in app/page.tsx (e.g.
import { Push } from "zeromq"; and const sock = new Push(); anywhere in your file),
start the development server npm run dev and visit http://localhost:3000.

Reproducible Container

  1. Clone this repository git@github.com:eulersson/zeromq.js-node.js-errors.git
  2. Build the Debian Docker container provided docker build -t zeromq-nextjs
  3. Run the Next.js development server container docker run --rm -it -p 3000:3000 nextjs-zeromq
  4. Visit http://localhost:3000 on your host browser.

Current vs. Expected behavior

error-screenshot
  • Result: Many "No native build was found for" errors server logs and an error screen on the browser.
  • Should: Not error.

Observations

If I change this line in the node-gyp-build/index.js to dir = '/absolute/path/to/node_modules/zeromq' then it works! It seems that it needs to be in .next/server... Because it looks for the prebuilds in there. I read and tried (unsuccessfully) the feature to includes files to the tracing process that happens where only the relevant files are moved to .next/server so a standalone server can use that reduced selection of dependencies.

Error Log

Full error log attached:
full-error-log.txt

Error log except:

root@3ae29fabb9db:/app# npm run dev

> my-app@0.1.0 dev
> next dev

   ▲ Next.js 14.1.0
   - Local:        http://localhost:3000

 ✓ Ready in 2.3s
 ○ Compiling /not-found ...

warn - No utility classes were detected in your source files. If this is unexpected, double-check the `content` option in your Tailwind CSS configuration.
warn - https://tailwindcss.com/docs/content-configuration
 ✓ Compiled / in 7.3s (471 modules)
Error: No native build was found for platform=linux arch=x64 runtime=node abi=115 uv=1 libc=glibc node=20.11.0 webpack=true
    loaded from: /app/.next/server

    at load.path (webpack-internal:///(rsc)/./node_modules/@aminya/node-gyp-build/index.js:50:11)
    at load (webpack-internal:///(rsc)/./node_modules/@aminya/node-gyp-build/index.js:20:32)
    at eval (webpack-internal:///(rsc)/./node_modules/zeromq/lib/native.js:6:123)
    at (rsc)/./node_modules/zeromq/lib/native.js (/app/.next/server/vendor-chunks/zeromq.js:40:1)
    at __webpack_require__ (/app/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./node_modules/zeromq/lib/index.js:7:16)
    at (rsc)/./node_modules/zeromq/lib/index.js (/app/.next/server/vendor-chunks/zeromq.js:30:1)
    at __webpack_require__ (/app/.next/server/webpack-runtime.js:33:42)
    at eval (webpack-internal:///(rsc)/./app/page.tsx:7:64)
    at (rsc)/./app/page.tsx (/app/.next/server/app/page.js:217:1)
    at Function.__webpack_require__ (/app/.next/server/webpack-runtime.js:33:42)
    at async eq (/app/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:402260)
    at async tr (/app/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:405987)
    at async tn (/app/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:406537)
    at async tn (/app/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:35:406668)
    at async tu (/app/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:36:2057)
    at async /app/node_modules/next/dist/compiled/next-server/app-page.runtime.dev.js:36:2564 {
  digest: '3408682970'
}
 ⨯ node_modules/@aminya/node-gyp-build/index.js (60:8) @ load.path
 ⨯ Error: No native build was found for platform=linux arch=x64 runtime=node abi=115 uv=1 libc=glibc node=20.11.0 webpack=true
    loaded from: /app/.next/server

    at __webpack_require__ (/app/.next/server/webpack-runtime.js:33:42)
    at __webpack_require__ (/app/.next/server/webpack-runtime.js:33:42)
    at eval (./app/page.tsx:7:64)
    at (rsc)/./app/page.tsx (/app/.next/server/app/page.js:217:1)
    at Function.__webpack_require__ (/app/.next/server/webpack-runtime.js:33:42)
    at async Promise.all (index 0)
null
[...] (see full error log)

Provide environment information

Operating System:
  Platform: linux
  Arch: x64
  Version: #1-Alpine SMP PREEMPT_DYNAMIC Mon, 05 Jun 2023 09:39:09 +0000
Binaries:
  Node: 20.11.0
  npm: 10.2.4
  Yarn: 1.22.19
  pnpm: N/A
Relevant Packages:
  next: 14.1.0
  eslint-config-next: 14.1.0
  react: 18.2.0
  react-dom: 18.2.0
  typescript: 5.3.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

Not sure

Which stage(s) are affected? (Select all that apply)

next dev (local), next build (local), next start (local)

Additional context

I cannot have this simple hello world app running on macOS 14.1.1 either...

NEXT-2485

@eulersson eulersson added the bug Issue was opened via the bug report template. label Feb 9, 2024
@eulersson
Copy link
Author

Will be fixed if all goes will with this issue resolution vercel/nft#391 with PR vercel/nft#392.

@styfle styfle added the linear: next Confirmed issue that is tracked by the Next.js team. label Feb 13, 2024
@eulersson
Copy link
Author

@vercel/nft version 0.26.4 fixes it.

styfle added a commit that referenced this issue Feb 15, 2024
The package [`zeromq`](https://unpkg.com/browse/zeromq@6.0.0-beta.19/)
contains native `.node` files that cannot be bundled (similar to
#60243)

- Fixes #61844

Closes NEXT-2507
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for 2 weeks. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. linear: next Confirmed issue that is tracked by the Next.js team. locked
Projects
None yet
2 participants