Closed iameli-streams closed 1 year ago
FWIW my use case was loading that config file to boot a Next.js server programatically. I wrote this to export the HTTP handler and work around this issue:
// Programmatic entrypoint into the Next.js server for `pkg` purposes.
const next = require("next");
const config = require("./next.config.js");
const { normalizeConfig } = require("next/dist/server/config-shared");
const {
PHASE_PRODUCTION_SERVER,
} = require("next/dist/shared/lib/constants.js");
const getApp = async () => {
// Workaround for https://github.com/vercel/pkg/issues/1962
const normalizedConfig = await normalizeConfig(
PHASE_PRODUCTION_SERVER,
config
);
const app = next({
dir: __dirname,
dev: false,
conf: normalizedConfig,
});
await app.prepare();
return app.getRequestHandler();
};
module.exports = getApp();
This issue is stale because it has been open 90 days with no activity. Remove the stale label or comment or this will be closed in 5 days. To ignore this issue entirely you can add the no-stale label
This issue is now closed due to inactivity, you can of course reopen or reference this issue if you see fit.
How do I re-open? Still a problem per my understanding.
What version of pkg are you using?
5.8.1
What version of Node.js are you using?
18.16,1
What operating system are you using?
Ubuntu 22.04
What CPU architecture are you using?
x86_64
What Node versions, OSs and CPU architectures are you building for?
node16-linux-x64 (EDIT: going to Node 18 did not fix the problem)
Describe the Bug
I'm getting an error importing a Next.js config file. Except... it knows it has the file, because it suggests it to me.
I DID mean to import
/snapshot/studio/packages/www/next.config.js
, which is why I did it. :confused:Running with
--debug
shows the file being imported several times:Expected Behavior
Working import
To Reproduce
I set up a minimal reproduction case here. For the record, all I'm trying to do is export a handler from the Next.js app so that it can be served from our API server for URLs that don't start with
/api
.Output: