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

App directory: Build fails due to secure-password / sodium-native #4234

Closed
tordans opened this issue Oct 15, 2023 · 6 comments · Fixed by #4276
Closed

App directory: Build fails due to secure-password / sodium-native #4234

tordans opened this issue Oct 15, 2023 · 6 comments · Fixed by #4276
Assignees
Labels
kind/bug Something isn't working status/done

Comments

@tordans
Copy link
Contributor

tordans commented Oct 15, 2023

What is the problem?

I am trying to npm run build my test app app on my MB Air M1 but the build fails.

I was not able to find anything in the NextJS docs/help channels. So I wonder if there is some part of Blitz that is added to NextJS in App-Directory-Mode that fails for me?

Buildings with app directory seems to require very different code paths, because on https://bun.sh/guides/ecosystem/nextjs it says "The Next.js App Router currently relies on Node.js APIs that Bun does not yet implement.".

Paste all your error logs here:

% npm run build

> [email protected] build
> blitz build

Loaded env from /Users/…/blitz-test-app/.env.local
Loaded env from /Users/…/blitz-test-app/.env
✔ Next.js was successfully patched with a React Suspense fix
✔ Routes manifest was successfully generated
 ⚠ Compiled with warnings

./node_modules/@blitzjs/auth/dist/index-server.cjs
Module not found: Can't resolve 'next-auth' in '/Users/…/blitz-test-app/node_modules/@blitzjs/auth/dist'
Did you mean './next-auth'?
Requests that should resolve in the current directory need to start with './'.
Requests that start with a name are treated as module requests and resolve within module directories (node_modules, /Users/…/blitz-test-app).
If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too.

Import trace for requested module:
./node_modules/@blitzjs/auth/dist/index-server.cjs
./src/blitz-client.ts
./src/app/layout.tsx

 ✓ Linting and checking validity of types
 ✓ Collecting page data
   Creating an optimized production build  .Error: No native build was found for platform=darwin arch=arm64 runtime=node abi=108 uv=1 armv=8 libc=glibc node=18.8.0 webpack=true
    loaded from: /Users/…/blitz-test-app/.next/server/chunks

    at load.resolve.load.path (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:2967)
    at load (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:1144)
    at 70597 (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:8377)
    at __webpack_require__ (/Users/…/blitz-test-app/.next/server/webpack-runtime.js:1:161)
    at 2103 (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:3719)
    at __webpack_require__ (/Users/…/blitz-test-app/.next/server/webpack-runtime.js:1:161)
    at 34694 (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:8437)
    at __webpack_require__ (/Users/…/blitz-test-app/.next/server/webpack-runtime.js:1:161)
    at 68414 (/Users/…/blitz-test-app/.next/server/app/(auth)/signup/page.js:1:3382)
    at __webpack_require__ (/Users/…/blitz-test-app/.next/server/webpack-runtime.js:1:161)

Error occurred prerendering page "/signup". Read more: https://nextjs.org/docs/messages/prerender-error
Error: No native build was found for platform=darwin arch=arm64 runtime=node abi=108 uv=1 armv=8 libc=glibc node=18.8.0 webpack=true
    loaded from: /Users/…/blitz-test-app/.next/server/chunks

    at load.resolve.load.path (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:2967)
    at load (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:1144)
    at 70597 (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:8377)
    at __webpack_require__ (/Users/…/blitz-test-app/.next/server/webpack-runtime.js:1:161)
    at 2103 (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:3719)
    at __webpack_require__ (/Users/…/blitz-test-app/.next/server/webpack-runtime.js:1:161)
    at 34694 (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:8437)
    at __webpack_require__ (/Users/…/blitz-test-app/.next/server/webpack-runtime.js:1:161)
    at 68414 (/Users/…/blitz-test-app/.next/server/app/(auth)/signup/page.js:1:3382)
    at __webpack_require__ (/Users/…/blitz-test-app/.next/server/webpack-runtime.js:1:161)
Error: No native build was found for platform=darwin arch=arm64 runtime=node abi=108 uv=1 armv=8 libc=glibc node=18.8.0 webpack=true
    loaded from: /Users/…/blitz-test-app/.next/server/chunks

    at load.resolve.load.path (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:2967)
    at load (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:1144)
    at 70597 (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:8377)
    at __webpack_require__ (/Users/…/blitz-test-app/.next/server/webpack-runtime.js:1:161)
    at 2103 (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:3719)
    at __webpack_require__ (/Users/…/blitz-test-app/.next/server/webpack-runtime.js:1:161)
    at 34694 (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:8437)
    at __webpack_require__ (/Users/…/blitz-test-app/.next/server/webpack-runtime.js:1:161)
    at 67415 (/Users/…/blitz-test-app/.next/server/chunks/264.js:1:103)
    at __webpack_require__ (/Users/…/blitz-test-app/.next/server/webpack-runtime.js:1:161)

Error occurred prerendering page "/login". Read more: https://nextjs.org/docs/messages/prerender-error
Error: No native build was found for platform=darwin arch=arm64 runtime=node abi=108 uv=1 armv=8 libc=glibc node=18.8.0 webpack=true
    loaded from: /Users/…/blitz-test-app/.next/server/chunks

    at load.resolve.load.path (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:2967)
    at load (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:1144)
    at 70597 (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:8377)
    at __webpack_require__ (/Users/…/blitz-test-app/.next/server/webpack-runtime.js:1:161)
    at 2103 (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:3719)
    at __webpack_require__ (/Users/…/blitz-test-app/.next/server/webpack-runtime.js:1:161)
    at 34694 (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:8437)
    at __webpack_require__ (/Users/…/blitz-test-app/.next/server/webpack-runtime.js:1:161)
    at 67415 (/Users/…/blitz-test-app/.next/server/chunks/264.js:1:103)
    at __webpack_require__ (/Users/…/blitz-test-app/.next/server/webpack-runtime.js:1:161)
Error: No native build was found for platform=darwin arch=arm64 runtime=node abi=108 uv=1 armv=8 libc=glibc node=18.8.0 webpack=true
    loaded from: /Users/…/blitz-test-app/.next/server/chunks

    at load.resolve.load.path (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:2967)
    at load (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:1144)
    at 70597 (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:8377)
    at __webpack_require__ (/Users/…/blitz-test-app/.next/server/webpack-runtime.js:1:161)
    at 2103 (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:3719)
    at __webpack_require__ (/Users/…/blitz-test-app/.next/server/webpack-runtime.js:1:161)
    at 34694 (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:8437)
    at __webpack_require__ (/Users/…/blitz-test-app/.next/server/webpack-runtime.js:1:161)
    at 59607 (/Users/…/blitz-test-app/.next/server/app/(auth)/reset-password/page.js:1:3459)
    at __webpack_require__ (/Users/…/blitz-test-app/.next/server/webpack-runtime.js:1:161)

Error occurred prerendering page "/reset-password". Read more: https://nextjs.org/docs/messages/prerender-error
Error: No native build was found for platform=darwin arch=arm64 runtime=node abi=108 uv=1 armv=8 libc=glibc node=18.8.0 webpack=true
    loaded from: /Users/…/blitz-test-app/.next/server/chunks

    at load.resolve.load.path (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:2967)
    at load (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:1144)
    at 70597 (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:8377)
    at __webpack_require__ (/Users/…/blitz-test-app/.next/server/webpack-runtime.js:1:161)
    at 2103 (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:3719)
    at __webpack_require__ (/Users/…/blitz-test-app/.next/server/webpack-runtime.js:1:161)
    at 34694 (/Users/…/blitz-test-app/.next/server/chunks/971.js:1:8437)
    at __webpack_require__ (/Users/…/blitz-test-app/.next/server/webpack-runtime.js:1:161)
    at 59607 (/Users/…/blitz-test-app/.next/server/app/(auth)/reset-password/page.js:1:3459)
    at __webpack_require__ (/Users/…/blitz-test-app/.next/server/webpack-runtime.js:1:161)
 ✓ Generating static pages (8/8)

> Export encountered errors on following paths:
	/(auth)/login/page: /login
	/(auth)/reset-password/page: /reset-password
	/(auth)/signup/page: /signup
   Creating an optimized production build  .%

Paste all relevant code snippets here:

https://github.com/FixMyBerlin/blitz-test

What are detailed steps to reproduce this?

  1. Checkout https://github.com/FixMyBerlin/blitz-test
  2. npm run build

Run blitz -v and paste the output here:

% blitz -v
Blitz version: 2.0.0-beta.33 (global)
Blitz version: 2.0.0-beta.34 (local)
macOS Ventura | darwin-arm64 | Node: v18.8.0


 Package manager: npm

  System:
    OS: macOS 13.6
    CPU: (8) arm64 Apple M1
    Memory: 40.33 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 18.8.0 - ~/.nvm/versions/node/v18.8.0/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v18.8.0/bin/yarn
    npm: 9.8.0 - ~/.nvm/versions/node/v18.8.0/bin/npm
  npmPackages:
    @blitzjs/auth: 2.0.0-beta.34 => 2.0.0-beta.34
    @blitzjs/next: 2.0.0-beta.34 => 2.0.0-beta.34
    @blitzjs/rpc: 2.0.0-beta.34 => 2.0.0-beta.34
    @prisma/client: 5.4.2 => 5.4.2
    blitz: 2.0.0-beta.34 => 2.0.0-beta.34
    next: 13.5.4 => 13.5.4
    prisma: 5.4.2 => 5.4.2
    react: 18.2.0 => 18.2.0
    react-dom: 18.2.0 => 18.2.0
    typescript: ^5.2.2 => 5.2.2

Please include below any other applicable logs and screenshots that show your problem:

No response

@tordans tordans added kind/bug Something isn't working status/triage labels Oct 15, 2023
@siddhsuresh
Copy link
Member

siddhsuresh commented Oct 15, 2023

@tordans thanks for the issue!

Regarding the missing next-auth package build issue, it has been fixed in #4235 and will be fixed in the next release.

Error: No native build was found for platform=darwin arch=arm64 runtime=node abi=108 uv=1 armv=8 libc=glibc node=18.8.0 webpack=true

This error directly related to secure-password or more directly sodium-native not able to find its pre-build for your environment.

I would like more information,

  • is this breaking the build or is a warning?
  • are you using app directory or pages?
  • are you using bun? (Just for info, not tried bun yet to run blitz due to the previous issues with the missing node:crypto utils)

@tordans
Copy link
Contributor Author

tordans commented Oct 15, 2023

is this breaking the build or is a warning?

The log output is all I get. When I run npm run start afterwards, it fails with… so I think the build is broken.

% npm run start

> [email protected] start
> blitz start

Loaded env from /Users/…/blitz-test-app-directory-error/.env.local
Loaded env from /Users/…/blitz-test-app-directory-error/.env
[Error: ENOENT: no such file or directory, open '/Users/…/blitz-test-app/.next/prerender-manifest.json'] {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/Users/…/blitz-test-app/.next/prerender-manifest.json'
}

are you using app directory or pages?

App directory. This is the same in our app at https://github.com/FixMyBerlin/atlas-app/blob/blitz-app-directory which are are migrating to blitz from plain react ATM and the test app at https://github.com/FixMyBerlin/blitz-test

are you using bun? (Just for info, not tried bun yet to run blitz due to the previous issues with the missing node:crypto utils)

No, regular node. On the homepage bun says it cannot do the app directory, yet https://bun.sh/guides/ecosystem/nextjs. We are not planning to use bun for NextJS.

@tordans tordans changed the title App directory: Error: No native build was found for platform=darwin arch=arm64 runtime=node abi=108 uv=1 armv=8 libc=glibc node=18.8.0 webpack=true App directory: Build fails due to secure-password / sodium-native Oct 24, 2023
@tordans
Copy link
Contributor Author

tordans commented Oct 24, 2023

@siddhsuresh we tested in https://github.com/FixMyBerlin/atlas-app/tree/blitz-app-directory-without-secure-password to remove SecurePassword and once we do this, I can successfully build the app without error.

I could not find any discussion or issue on this topic at https://github.com/vercel/next.js.

We are now trying to work around it by using an OAuth provider exclusively.

tordans added a commit to FixMyBerlin/blitz-test that referenced this issue Nov 30, 2023
We need this to work around blitz-js/blitz#4234 in order to test the pages in a build env.
@guilt
Copy link

guilt commented Jan 10, 2024

I can confirm I had the same issue. SecurePassword depends on libsodium-native and requires that node-gyp be configured properly and with an installed Python, Visual Studio 2019 Dev Tools on Windows.

This is not great for a lot of people and the developer experience is far from optimum with this.

Could you please make this work with a fork/better maintained version that probably uses a newer version and without requiring node-gyp?

We are evaluating blitz and this came out as a blocker.

@siddhsuresh
Copy link
Member

@guilt I agree, we are investigating the possible solutions that blitz can take up to solve this issue.

@siddhsuresh
Copy link
Member

siddhsuresh commented Jan 14, 2024

@tordans @guilt I have published a fix with the tag next--missing-prebuilds. If possible please test it out and let me know if it fixes the issue on your end. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Something isn't working status/done
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants