diff --git a/packages/next/bin/next.ts b/packages/next/bin/next.ts index 283e0996b747..bba1a9c9a009 100755 --- a/packages/next/bin/next.ts +++ b/packages/next/bin/next.ts @@ -105,6 +105,22 @@ if (process.env.NODE_ENV) { ;(process.env as any).NODE_ENV = process.env.NODE_ENV || defaultEnv +// x-ref: https://github.com/vercel/next.js/pull/34688#issuecomment-1047994505 +if (process.versions.pnp === '3') { + const nodeVersionParts = process.versions.node + .split('.') + .map((v) => Number(v)) + + if ( + nodeVersionParts[0] < 16 || + (nodeVersionParts[0] === 16 && nodeVersionParts[1] < 14) + ) { + log.warn( + 'Node.js 16.14+ is required for Yarn PnP 3.20+. More info: https://github.com/vercel/next.js/pull/34688#issuecomment-1047994505' + ) + } +} + // Make sure commands gracefully respect termination signals (e.g. from Docker) process.on('SIGTERM', () => process.exit(0)) process.on('SIGINT', () => process.exit(0)) diff --git a/test/e2e/yarn-pnp/test/utils.ts b/test/e2e/yarn-pnp/test/utils.ts index 1d616f084cd9..57ceb10c050e 100644 --- a/test/e2e/yarn-pnp/test/utils.ts +++ b/test/e2e/yarn-pnp/test/utils.ts @@ -41,6 +41,12 @@ export function runTests(example = '') { }) afterAll(() => next?.destroy()) + it('should warn on not fully supported node versions', async () => { + expect(next.cliOutput).toContain( + 'Node.js 16.14+ is required for Yarn PnP 3.20+. More info' + ) + }) + it(`should compile and serve the index page correctly ${example}`, async () => { const res = await fetchViaHTTP(next.url, '/') expect(res.status).toBe(200)