From d1f616930de4a8312e3441410098d9f248855d9d Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Thu, 4 Feb 2021 21:01:21 -0500 Subject: [PATCH] build: set minimum Node.js version to 12.13 This change provides an improved performance baseline as well as access to newer Node.js APIs and Javascript language features which the Angular CLI will now be able to leverage. BREAKING CHANGE: Node.js version 10 will become EOL on 2021-04-30. Angular CLI 12 will require Node.js 12.13+ or 14.15+. Node.js 12.13 and 14.15 are the first LTS releases for their respective majors. --- .circleci/config.yml | 6 ++--- lib/packages.ts | 2 +- package.json | 2 +- packages/angular/cli/bin/ng | 26 +++++++++++++++---- .../angular_devkit/benchmark/package.json | 4 --- 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3722628dd33d..3bfc219998ae 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -77,9 +77,9 @@ commands: at: *workspace_location setup_windows: steps: - - run: nvm install 12.1.0 - - run: nvm use 12.1.0 - - run: npm install -g yarn@1.17.3 + - run: nvm install 12.13 + - run: nvm use 12.13 + - run: npm install -g yarn@1.22.10 - run: node --version - run: yarn --version diff --git a/lib/packages.ts b/lib/packages.ts index 4606982e3c2c..fb1f5df02417 100644 --- a/lib/packages.ts +++ b/lib/packages.ts @@ -87,7 +87,7 @@ function loadPackageJson(p: string) { // Overwrite engines to a common default. case 'engines': pkg['engines'] = { - 'node': '>= 10.13.0', + 'node': '>= 12.13.0', 'npm': '^6.11.0', 'yarn': '>= 1.13.0', }; diff --git a/package.json b/package.json index 705ea1cad4fe..24cd74d44dc7 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "url": "https://github.com/angular/angular-cli.git" }, "engines": { - "node": ">=10.13.0 <13.0.0", + "node": ">=12.13.0 <15.0.0", "yarn": ">=1.22.4" }, "author": "Angular Authors", diff --git a/packages/angular/cli/bin/ng b/packages/angular/cli/bin/ng index e9e7198c65d5..2a393779cbdf 100755 --- a/packages/angular/cli/bin/ng +++ b/packages/angular/cli/bin/ng @@ -14,12 +14,28 @@ try { // These may not support ES2015 features such as const/let/async/await/etc. // These would then crash with a hard to diagnose error message. // tslint:disable-next-line: no-var-keyword -var version = process.versions.node.split('.').map(part => Number(part)); -if (version[0] < 10 || version[0] === 11 || (version[0] === 10 && version[1] < 13)) { +var version = process.versions.node.split('.').map((part) => Number(part)); +if (version[0] % 2 === 1 && version[0] > 14) { + // Allow new odd numbered releases with a warning (currently v15+) + console.warn( + 'Node.js version ' + + process.version + + ' detected.\n' + + 'Odd numbered Node.js versions will not enter LTS status and should not be used for production.' + + ' For more information, please see https://nodejs.org/en/about/releases/.', + ); +} else if ( + version[0] < 12 || + version[0] === 13 || + (version[0] === 12 && version[1] < 13) || + (version[0] === 14 && version[1] < 15) +) { console.error( - 'Node.js version ' + process.version + ' detected.\n' + - 'The Angular CLI requires a minimum Node.js version of either v10.13 or v12.0.\n\n' + - 'Please update your Node.js version or visit https://nodejs.org/ for additional instructions.\n' + 'Node.js version ' + + process.version + + ' detected.\n' + + 'The Angular CLI requires a minimum Node.js version of either v12.13 or v14.15.\n\n' + + 'Please update your Node.js version or visit https://nodejs.org/ for additional instructions.\n', ); process.exitCode = 3; diff --git a/packages/angular_devkit/benchmark/package.json b/packages/angular_devkit/benchmark/package.json index 4a482add2b80..09c9c3c3de98 100644 --- a/packages/angular_devkit/benchmark/package.json +++ b/packages/angular_devkit/benchmark/package.json @@ -9,10 +9,6 @@ "keywords": [ "benchmark" ], - "engines": { - "node": ">= 10.13.0", - "npm": ">= 6.2.0" - }, "dependencies": { "@angular-devkit/core": "0.0.0", "ansi-colors": "4.1.1",