Skip to content

Commit 276b347

Browse files
authored
Allow, but warn for, pre-release versions of Node (#23970)
* Allow, but warn for, pre-release versions of Node * Add tests * Re-add commented-out warning for next EOL Node version
1 parent f7fbce7 commit 276b347

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

packages/gatsby-cli/src/__tests__/index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,20 @@ describe(`error handling`, () => {
5858
expect.stringContaining(`https://gatsby.dev/upgrading-node-js`)
5959
)
6060
})
61+
62+
it(`allows prerelease versions`, () => {
63+
const { reporter } = setup(`v15.0.0-pre`)
64+
65+
expect(reporter.panic).not.toHaveBeenCalled()
66+
})
67+
68+
it(`warns on prerelease versions`, () => {
69+
const { reporter } = setup(`v15.0.0-pre`)
70+
71+
expect(reporter.warn).toHaveBeenCalledWith(
72+
expect.stringContaining(`prerelease`)
73+
)
74+
})
6175
})
6276

6377
// describe(`deprecation warning`, () => {

packages/gatsby-cli/src/index.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,34 @@ updateNotifier({ pkg }).notify({ isGlobal: true })
2727
const MIN_NODE_VERSION = `10.13.0`
2828
// const NEXT_MIN_NODE_VERSION = `10.13.0`
2929

30-
if (!semver.satisfies(process.version, `>=${MIN_NODE_VERSION}`)) {
30+
const { version } = process
31+
32+
if (
33+
!semver.satisfies(version, `>=${MIN_NODE_VERSION}`, {
34+
includePrerelease: true,
35+
})
36+
) {
3137
report.panic(
3238
report.stripIndent(`
33-
Gatsby requires Node.js ${MIN_NODE_VERSION} or higher (you have ${process.version}).
39+
Gatsby requires Node.js ${MIN_NODE_VERSION} or higher (you have ${version}).
3440
Upgrade Node to the latest stable release: https://gatsby.dev/upgrading-node-js
3541
`)
3642
)
3743
}
3844

39-
// if (!semver.satisfies(process.version, `>=${NEXT_MIN_NODE_VERSION}`)) {
45+
if (semver.prerelease(version)) {
46+
report.warn(
47+
report.stripIndent(`
48+
You are currently using a prerelease version of Node (${version}), which is not supported.
49+
You can use this for testing, but we do not recommend it in production.
50+
Before reporting any bugs, please test with a supported version of Node (>=${MIN_NODE_VERSION}).`)
51+
)
52+
}
53+
54+
// if (!semver.satisfies(version, `>=${NEXT_MIN_NODE_VERSION}`)) {
4055
// report.warn(
4156
// report.stripIndent(`
42-
// Node.js ${process.version} has reached End of Life status on 31 December, 2019.
57+
// Node.js ${version} has reached End of Life status on 31 December, 2019.
4358
// Gatsby will only actively support ${NEXT_MIN_NODE_VERSION} or higher and drop support for Node 8 soon.
4459
// Please upgrade Node.js to a currently active LTS release: https://gatsby.dev/upgrading-node-js
4560
// `)

0 commit comments

Comments
 (0)