I have a similar patch to @lewisking , so it will work by creating a prebuild.js
and executing it as a prebuild
script in package.json
.
console.log("********* PREBUILDING");
const path = require("node:path");
const fs = require("fs");
const baseDir = process.cwd();
// /node_modules/@netlify/plugin-nextjs/lib/templates/requireHooks.js
const prebuildScripts = async () => {
const file = path.join(
baseDir,
"/node_modules",
"@netlify/plugin-nextjs/lib/templates/requireHooks.js"
);
const content = await fs.promises.readFile(file, "utf-8");
await fs.promises.writeFile(
file,
content.replace(
"const reactMode = process.env.__NEXT_PRIVATE_PREBUNDLED_REACT || 'default';",
"const reactMode = process.env.__NEXT_PRIVATE_PREBUNDLED_REACT || 'next';"
)
);
};
prebuildScripts();
This seems to have worked for me on Next 13.4.9, with the appDir
experimental config still set to true
.
I’ve updated this ticket [Bug]: ISR Working Locally But Not Working on Netify · Issue #2127 · netlify/next-runtime · GitHub, so hopefully some work can be done to resolve the issue
But at least for now, I have a fix