[Bug]: Vercel build fails to load next.config.js
Provide environment information
Next.js 14.2.3 @serwist/next: 9.0.2
Which project is this issue for?
@serwist/next
Link to reproduction - Issues with a link to complete (but minimal) reproduction code help us address them faster
Will include later
To reproduce
- Create a T3-App
bun create t3-app@latest
-
Follow the steps described here: https://serwist.pages.dev/docs/next/getting-started
-
Deploy to Vercel
Describe the bug
Building the app locally works fine, but building in Vercel fails with the following logs/error:
[01:02:29.465] ⨯ Failed to load next.config.js, see more info here https://nextjs.org/docs/messages/next-config-error
[01:02:29.471]
[01:02:29.472] > Build error occurred
[01:02:29.473] file:///vercel/path0/node_modules/glob/dist/esm/pattern.js:2
[01:02:29.473] import { GLOBSTAR } from 'minimatch';
[01:02:29.473] ^^^^^^^^
[01:02:29.473] SyntaxError: Named export 'GLOBSTAR' not found. The requested module 'minimatch' is a CommonJS module, which may not support all module.exports as named exports.
[01:02:29.473] CommonJS modules can always be imported via the default export, for example using:
[01:02:29.473]
[01:02:29.474] import pkg from 'minimatch';
[01:02:29.474] const { GLOBSTAR } = pkg;
[01:02:29.474]
[01:02:29.474] at ModuleJob._instantiate (node:internal/modules/esm/module_job:134:21)
[01:02:29.474] at async ModuleJob.run (node:internal/modules/esm/module_job:217:5)
[01:02:29.474] at async ModuleLoader.import (node:internal/modules/esm/loader:316:24)
[01:02:29.474] at async loadConfig (/vercel/path0/node_modules/next/dist/server/config.js:698:36)
[01:02:29.474] at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/trace/trace.js:154:20)
[01:02:29.474] at async /vercel/path0/node_modules/next/dist/build/index.js:372:28
[01:02:29.474] at async Span.traceAsyncFn (/vercel/path0/node_modules/next/dist/trace/trace.js:154:20)
[01:02:29.474] at async build (/vercel/path0/node_modules/next/dist/build/index.js:366:9)
[01:02:29.480] error: script "vercel-build" exited with code 1
[01:02:29.484] Error: Command "bun run vercel-build" exited with 1
Expected behavior
It should build.
Screenshots (if relevant)
No response
Additional information (if relevant)
next.config.js
import withSerwistInit from "@serwist/next";
const withSerwist = withSerwistInit({
// Note: This is only an example. If you use Pages Router,
// use something else that works, such as "service-worker/index.ts".
swSrc: "src/app/sw.ts",
swDest: "public/sw.js",
});
/**
* Run `build` or `dev` with `SKIP_ENV_VALIDATION` to skip env validation. This is especially useful
* for Docker builds.
*/
await import("./src/env.js");
/** @type {import("next").NextConfig} */
const config = {};
export default withSerwist(config);
Everything else is the default from create-t3-app.
Sounds like it might be a package resolution issue with serwist + bun. Got multiple projects running serwist (of which, atleast 4 of em are started from the t3-app startingpoint) and when using any other package manager, all is fine.
Seems that glob/minimatch's ESM/CJS hybrid support might be a bit weird. Suggest you open a new issue over there!
same issue with t3 and bun on Vercel
same issue with t3 and bun on Vercel
aka, same as OP...
I have the same issue with
"next": "^14.3.0-canary.79"
"@serwist/next": "^9.0.2",
But I managed to work it around by running:
bun i minimatch@latest
and amending package.json with
"overrides": {
"minimatch": "$minimatch"
}
There are still warnings. But at least I can build the project, while waiting for the proper fix in @serwist/next
This issue is stale because it has been open for 30 days with no activity.
experiencing a similar issue, though it seems to happen on some builds and not others. anyone got a workaround?
experiencing a similar issue, though it seems to happen on some builds and not others. anyone got a workaround?
As mentioned in previous comments on this issue, this seems to be a bun specific issue. This is probably related to package resolution, meaning the only workaround would be to not use bun.
Just a heads-up—I seem to be able to install Serwist with Bun on Vercel now. Probably time to close this issue? :)
This issue is stale because it has been open for 30 days with no activity.
This issue was closed because it has been inactive for 14 days since being marked as stale.
@DuCanhGH what did you do to get it to work properly?
@yungyoda nothing special. Just deploy it like normal.