Skip to content

Commit

Permalink
Add warning for Yarn PnP v3 with Node.js < 16.14 (#34818)
Browse files Browse the repository at this point in the history
* Add warning for Yarn PnP v3 with Node.js < 16.14

* Apply suggestions from code review

Co-authored-by: Steven <steven@ceriously.com>

* Apply suggestions from code review

Co-authored-by: Steven <steven@ceriously.com>

* lint-fix

Co-authored-by: Steven <steven@ceriously.com>
  • Loading branch information
ijjk and styfle committed Feb 25, 2022
1 parent 35a1af4 commit d09fb1d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/next/bin/next.ts
Expand Up @@ -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))
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/yarn-pnp/test/utils.ts
Expand Up @@ -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)
Expand Down

0 comments on commit d09fb1d

Please sign in to comment.