[π Bug]: Unsupported Node.js version! Your version: undefined
richtera opened this issue Β· comments
next-on-pages environment related information
β― yarn next-on-pages --info
System:
Platform: darwin
Arch: arm64
Version: Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:49 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6020
CPU: (12) arm64 Apple M2 Max
Memory: 32 GB
Shell: /bin/zsh
Package Manager Used: yarn (4.2.2)
Relevant Packages:
@cloudflare/next-on-pages: 1.11.3
vercel: N/A
next: 14.2.3
Description
For some reason I cannot currently compile an app with next-on-pages. I have lots of apps using this, but for this app, the web sandbox doesn't have process.version defined and therefore it serializes a process.exit() into the code causing it to error out that process.exit is not supported in the edge runtime. I can't quite tell what is triggering the missing process.version, because the node runtime obviously has process.version defined. I made sure to add a webpack config to defined process.version, but that didn't help, because it happens on the sandbox and not during the webpack build.
Reproduction
git checkout https://github.com/richtera/wownar
cd wownar
yarn
yarn pages:build
The project is setup to work with asdf or mise and will attempt to use node 20.5.1, so you might need mise install nodejs
or asdf install nodejs
.
the output should look like this
yarn pages:build
β‘οΈ @cloudflare/next-on-pages CLI v.1.11.3
β‘οΈ Detected Package Manager: yarn (4.2.2)
β‘οΈ Preparing project...
β‘οΈ Project is ready
β‘οΈ Building project...
β² β€ YN0000: Β· Yarn 4.2.2
β² β€ YN0000: β Resolution step
β² β€ YN0085: β + vercel@npm:34.2.2, @cspotcode/source-map-support@npm:0.8.1, @edge-runtime/format@npm:2.2.1, @edge-runtime/node-utils@npm:2.3.0, and 332 more.
β² β€ YN0000: β Completed in 0s 512ms
β² β€ YN0000: β Fetch step
β² β€ YN0013: β 317 packages were added to the project (+ 188.65 MiB).
β² β€ YN0000: β Completed in 0s 264ms
β² β€ YN0000: β Link step
β² β€ YN0007: β esbuild@npm:0.14.47 must be built because it never has been before or the last one failed
β² β€ YN0000: β Completed in 0s 818ms
β² β€ YN0000: Β· Done in 1s 631ms
β²
β² Vercel CLI 34.2.2
β² Warning: Detected "engines": { "node": "20.5.1" } in your `package.json` with major.minor.patch, but only major Node.js Version can be selected. Learn More: http://vercel.link/node-version
β² Installing dependencies...
β² β€ YN0000: Β· Yarn 4.2.2
β² β€ YN0000: β Resolution step
β² β€ YN0000: β Completed
β² β€ YN0000: β Post-resolution validation
β² β€ YN0060: β eslint is listed by your project with version 9.3.0, which doesn't satisfy what eslint-config-next (p90fe7) and other dependencies request (^8.56.0).
β² β€ YN0002: β Wownar@workspace:. doesn't provide vercel (p38e12), requested by @cloudflare/next-on-pages.
β² β€ YN0002: β Wownar@workspace:. doesn't provide wrangler (p84dba), requested by @cloudflare/next-on-pages.
β² β€ YN0086: β Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code.
β² β€ YN0000: β Completed
β² β€ YN0000: β Fetch step
β² β€ YN0000: β Completed in 0s 252ms
β² β€ YN0000: β Link step
β² β€ YN0000: β Completed
β² β€ YN0000: Β· Done with warnings in 0s 420ms
β² Detected Next.js version: 14.2.3
β² Running "yarn run build"
β² Node.js version: v20.5.1
β² β² Next.js 14.2.3
β² - Environments: .env
β²
β² Creating an optimized production build ...
β² β Compiled successfully
β² Linting and checking validity of types ...
β² β¨― ESLint: Invalid Options: - Unknown options: useEslintrc, extensions - 'extensions' has been removed.
β² Collecting page data ...
β² Unsupported Node.js version! Your version: undefined. Required version: >=19.9.0.
β² Unsupported Node.js version! Your version: undefined. Required version: >=19.9.0.
β² /Users/andy/Development/wownar/node_modules/next/dist/server/web/sandbox/context.js:108
β² throw error;
β² ^
β²
β² Error: A Node.js API is used (process.exit) which is not supported in the Edge Runtime.
β² Learn more: https://nextjs.org/docs/api-reference/edge-runtime
β² at throwUnsupportedAPIError (/Users/andy/Development/wownar/node_modules/next/dist/server/web/sandbox/context.js:105:19)
β² at Object.<anonymous> (/Users/andy/Development/wownar/node_modules/next/dist/server/web/sandbox/context.js:123:32)
β² at 82437 (/Users/andy/Development/wownar/.next/server/edge-chunks/668.js:1:762)
β² at t (/Users/andy/Development/wownar/.next/server/edge-runtime-webpack.js:1:128)
β² at 41090 (/Users/andy/Development/wownar/.next/server/app/api/cast/route.js:1:1560)
β² at t (/Users/andy/Development/wownar/.next/server/edge-runtime-webpack.js:1:128)
β² at 75627 (/Users/andy/Development/wownar/.next/server/app/api/cast/route.js:1:541)
β² at t (/Users/andy/Development/wownar/.next/server/edge-runtime-webpack.js:1:128)
β² at t (/Users/andy/Development/wownar/.next/server/app/api/cast/route.js:1:1629)
β² at /Users/andy/Development/wownar/.next/server/app/api/cast/route.js:1:1654
β² Unsupported Node.js version! Your version: undefined. Required version: >=19.9.0.
β²
β² > Build error occurred
β² Error: Failed to collect page data for /api/cast
β² at /Users/andy/Development/wownar/node_modules/next/dist/build/utils.js:1268:15
β² at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
β² type: 'Error'
β² }
β² Error: Command "yarn run build" exited with 1
The repo is a clone of https://github.com/neynarxyz/farcaster-examples/tree/main/wownar with added npm upgrades, a local install of @cloudflare/next-on-pages and the required .tool-versions, .node-version and mise.yaml to make it build everywhere.
Pages Deployment Method
Pages CI (GitHub/GitLab integration)
Pages Deployment ID
No response
Additional Information
I have tried both Pages CI and local builds, but neither work right now.
I can help fix this bug as long as I know where the sandbox is initializing the fake process object containing for example { browser: true }
Would you like to help?
- Would you like to help fixing this bug?
Seems like a nextjs problem. Adding a bug there.
function createProcessPolyfill() {
const processPolyfill = {
env: buildEnvironmentVariablesFrom(),
version: process.version // ADDING THIS
};
const overridenValue = {};
for (const key of Object.keys(process)){
if (key === "env" || key === "version") continue; // AND key === "version"
Object.defineProperty(processPolyfill, key, {
get () {
if (overridenValue[key] !== undefined) {
return overridenValue[key];
}
if (typeof process[key] === "function") {
return ()=>throwUnsupportedAPIError(`process.${key}`);
}
return undefined;
},
set (value) {
overridenValue[key] = value;
},
enumerable: false
});
}
return processPolyfill;
}
``` makes the compile go through further.
Thanks a bunch for the issue @richtera ππ
As I can see from the logs you shared, and as you mentioned, that this seems to be an issue with Next.js itself and not next-on-pages (the error happens during the Next.js build before next-on-pages does anything), so if it's ok by you I'm going to close this issue as I believe that the right place for this is the Next.js repository (where you already created an issue and opened a PR to fix it! πͺ π π€© ).
If you disagree please let me know and feel free to reopen the issue.