Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(gatsby-cli): Add notice for Node 8 EOL #20466

Merged
merged 5 commits into from
Jan 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions docs/docs/upgrading-node-js.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,18 @@ Run `node -v` in a terminal to see which version of Node.js you have.

```shell
node -v
v10.16.0
v10.18.0
```

This example shows Node.js version 10, specifically v10.16.0.
This example shows Node.js version 10, specifically v10.18.0.

## Upgrading from Node.js version 6
## Upgrading from Node.js version 8

Node.js version 6 reached _End-of-life_ status on 30th April 2019. Many of Gatsby's dependencies are updating to Node.js version 8 and above. Gatsby must also update in order to deliver new features and bug fixes more quickly.
Node.js version 8 reached _End-of-life_ status on December 31, 2019. Many of Gatsby's dependencies are updating to Node.js version 10 and above. Gatsby must also update in order to deliver new features and bug fixes more quickly.

Generally, it's recommended to use [the Node version whose status is _Active LTS_](https://github.com/nodejs/Release#nodejs-release-working-group) (Node 10 at time of writing). However, in this document, you'll learn how to update from Node 6 to Node 8 as this is likely to be the least disruptive upgrade for you.
Generally, it's recommended to use [the Node version whose status is _Active LTS_](https://github.com/nodejs/Release#nodejs-release-working-group) (Node 10 at time of writing).

> What about Node.js 7? Stable versions of Node.js are evenly numbered releases - Node.js 6, Node.js 8, Node.js 10 etc. Only use uneven release numbers if you'd like to try cutting-edge and experimental features.
> What about Node.js 9? Stable versions of Node.js are evenly numbered releases - Node.js 6, Node.js 8, Node.js 10 etc. Only use uneven release numbers if you'd like to try cutting-edge and experimental features.

There are multiple ways to update your version of Node.js depending on how you originally installed it. Read on to find the best approach for you.

Expand All @@ -37,7 +37,7 @@ This is the recommended way to install a newer version of Node.

You will have homebrew installed on your computer if you [followed part zero of the Gatsby tutorial](https://www.gatsbyjs.org/tutorial/part-zero/#-install-nodejs-and-npm). Homebrew is a program that allows you to install specific versions of Node.js (and other software).

To update from Node.js 6 to Node.js 8 using Homebrew, open a terminal and run the following commands:
To update from Node.js 8 to Node.js 10 using Homebrew, open a terminal and run the following commands:

```shell
brew search node
Expand All @@ -53,10 +53,10 @@ leafnode node ✔ node@8
libbitcoin-node node-build node_exporter nodenv
```

You're interested in the next stable version of Node.js after Node.js 6, which is Node.js 8. Homebrew makes this available in a package called `node@8`. Run:
You're interested in the next stable version of Node.js after Node.js 8, which is Node.js 10. Homebrew makes this available in a package called `node@10`. Run:

```shell
brew install node@8
brew install node@10
```

Once that's complete, run:
Expand All @@ -65,7 +65,7 @@ Once that's complete, run:
node -v
```

to confirm that you've upgraded from Node.js version 6 up to version 8.
to confirm that you've upgraded from Node.js version 8 up to version 10.

### Using a Node.js version management package

Expand All @@ -84,11 +84,11 @@ nvm
in a terminal to see if nvm is installed on your system. If it's installed, you can run:

```shell
nvm install 8
nvm alias default 8
nvm install 10
nvm alias default 10
```

to install and use Node.js version 8.
to install and use Node.js version 10.

[Check nvm's documentation for further instructions](https://github.com/nvm-sh/nvm).

Expand All @@ -100,7 +100,7 @@ Run:
n
```

in a terminal to see if n is installed on your system. If it's installed, you can run `n 8` to install and use Node.js version 8.
in a terminal to see if n is installed on your system. If it's installed, you can run `n 10` to install and use Node.js version 10.

[Check n's documentation for further instructions](https://github.com/tj/n).

Expand All @@ -116,4 +116,4 @@ Gatsby takes backwards compatibility seriously and aims to support older version

Gatsby also relies on a huge ecosystem of JavaScript dependencies. As the ecosystem moves away from older, unsupported Node.js versions we have to keep pace to ensure that bugs can be fixed and new features can be released.

In this document, you learned how you upgrade from Node.js version 6 (which has reached _End of Life_ status) to Node.js version 8 (which has reached _Maintenance_) status.
In this document, you learned how you upgrade from Node.js version 8 (which has reached _End of Life_ status) to Node.js version 10.
11 changes: 11 additions & 0 deletions packages/gatsby-cli/src/__tests__/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ jest.mock(`../reporter`, () => {
panic: jest.fn(),
log: jest.fn(),
stripIndent: jest.fn(str => str),
warn: jest.fn(),
}
})
jest.mock(`../create-cli`)
Expand Down Expand Up @@ -56,6 +57,16 @@ describe(`error handling`, () => {
})
})

describe(`deprecation warning`, () => {
it(`warns on Node < 10.13.0`, () => {
const { reporter } = setup(`v10.12.0`)

expect(reporter.warn).toHaveBeenCalledWith(
expect.stringContaining(`https://gatsby.dev/upgrading-node-js`)
)
})
})

describe(`normal behavior`, () => {
it(`does not panic on Node >= 8.0.0`, () => {
;[`8.0.0`, `8.9.0`, `10.0.0`, `12.0.0`, `13.0.0`].forEach(version => {
Expand Down
17 changes: 14 additions & 3 deletions packages/gatsby-cli/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,28 @@ if (useJsonLogger) {
// Check if update is available
updateNotifier({ pkg }).notify({ isGlobal: true })

const MIN_NODE_VERSION = `>=8.0.0`
const MIN_NODE_VERSION = `8.0.0`
const NEXT_MIN_NODE_VERSION = `10.13.0`

if (!semver.satisfies(process.version, MIN_NODE_VERSION)) {
if (!semver.satisfies(process.version, `>=${MIN_NODE_VERSION}`)) {
report.panic(
report.stripIndent(`
Gatsby requires Node.js v8 or higher (you have ${process.version}).
Gatsby requires Node.js ${MIN_NODE_VERSION} or higher (you have ${process.version}).
Upgrade Node to the latest stable release: https://gatsby.dev/upgrading-node-js
`)
)
}

if (!semver.satisfies(process.version, `>=${NEXT_MIN_NODE_VERSION}`)) {
report.warn(
report.stripIndent(`
Node.js ${process.version} has reached End of Life status on 31 December, 2019.
Gatsby will only actively support ${NEXT_MIN_NODE_VERSION} or higher and drop support for Node 8 soon.
Copy link
Contributor

@muescha muescha Jan 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe remove here the version number so on the next time we don't need to change the numbers...

Suggested change
Gatsby will only actively support ${NEXT_MIN_NODE_VERSION} or higher and drop support for Node 8 soon.
Gatsby will only actively support ${NEXT_MIN_NODE_VERSION} or higher and drop support for earlier Node versions soon.

if ok i can create a follow up PR

Please upgrade Node.js to a currently active LTS release: https://gatsby.dev/upgrading-node-js
sidharthachatterjee marked this conversation as resolved.
Show resolved Hide resolved
`)
)
}

process.on(`unhandledRejection`, reason => {
// This will exit the process in newer Node anyway so lets be consistent
// across versions and crash
Expand Down