fix: Improve validation of min supported Node version

This commit is contained in:
Piotr Grzesik 2022-02-07 18:41:25 +01:00
parent 480d74ec58
commit bf084f3edd
3 changed files with 13 additions and 7 deletions

View File

@ -93,7 +93,7 @@ Read the [**complete v3 Upgrade Guide**](https://www.serverless.com/framework/do
- Duplicate plugin definition in configuration will now result in an error instead of a warning.
- Using `--aws-s3-accelerate` flag will result in an error instead of deprecation when custom S3 bucket is used.
- Removed support for `provider.disableDefaultOutputExportNames`
- Node.js versions lower than 12 is no longer supported
- Node.js versions lower than v12.13.0 (LTS) is no longer supported
- Lifecycle events marked as deprecated (in context of v1) are no longer evaluated
### Features

View File

@ -11,15 +11,21 @@
const isMainModule = !EvalError.$serverlessCommandStartTime;
if (isMainModule) EvalError.$serverlessCommandStartTime = process.hrtime();
const nodeVersion = Number(process.version.split('.')[0].slice(1));
const minimumSupportedVersion = 12;
const nodeVersionMajor = Number(process.version.split('.')[0].slice(1));
const nodeVersionMinor = Number(process.version.split('.')[1]);
const minimumSupportedVersionMajor = 12;
const minimumSupportedVersionMinor = 13;
if (nodeVersion < minimumSupportedVersion) {
if (
nodeVersionMajor < minimumSupportedVersionMajor ||
(nodeVersionMajor === minimumSupportedVersionMajor &&
nodeVersionMinor < minimumSupportedVersionMinor)
) {
const serverlessVersion = Number(require('../package.json').version.split('.')[0]);
process.stderr.write(
`\x1b[91mError: Serverless Framework v${serverlessVersion} does not support ` +
`Node.js v${nodeVersion}. Please upgrade Node.js to the latest ` +
`LTS version (v${minimumSupportedVersion} is a minimum supported version)\x1b[39m\n`
`Node.js ${process.version}. Please upgrade Node.js to the latest ` +
`LTS version (v${minimumSupportedVersionMajor}.${minimumSupportedVersionMinor}.0 is a minimum supported version)\x1b[39m\n`
);
process.exit(1);
}

View File

@ -75,7 +75,7 @@ You will find below a complete list of all breaking changes. All those breaking
### CLI commands and options
The `serverless` CLI no longer runs on Node v10 because [that version is obsolete](https://endoflife.date/nodejs): upgrade to v12 or greater to run `serverless` on your machine.
The `serverless` CLI no longer runs on Node v10 because [that version is obsolete](https://endoflife.date/nodejs): upgrade to v12.13.0 (LTS) or greater to run `serverless` on your machine.
The `serverless` CLI used to accept free-form CLI options. This feature was deprecated and has been removed. The main reason is that this prevented us from detecting typos in options, which sometimes created unexpected situations and overall a bad user experience. [Learn more about this change](../deprecations.md#handling-of-unrecognized-cli-options).