Skip to content

Commit

Permalink
feat(@angular/cli): officially support Node.js v16
Browse files Browse the repository at this point in the history
Node.js v16 will be entering an LTS state prior to the release of Angular v13 which allows Node.js v16 to be marked as officially supported by the Angular CLI. The initial bootstrapping check now adds Node.js v16 to the output message in the event of an unsupported Node.js version.
NOTE: Prior to the final v13 release, the Node.js v16 minor should be updated to the actual LTS version once available.
  • Loading branch information
clydin authored and filipesilva committed Oct 6, 2021
1 parent a8855a0 commit 9fe5575
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/packages.ts
Expand Up @@ -85,7 +85,7 @@ function loadPackageJson(p: string) {
// Overwrite engines to a common default.
case 'engines':
pkg['engines'] = {
'node': '^12.20.0 || >=14.0.0',
'node': '^12.20.0 || ^14.15.0 || >=16.10.0',
'npm': '^6.11.0 || ^7.5.6',
'yarn': '>= 1.13.0',
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -40,7 +40,7 @@
"url": "https://github.com/angular/angular-cli.git"
},
"engines": {
"node": "^12.20.0 || ^14.0.0",
"node": "^12.20.0 || ^14.15.0 || ^16.10.0",
"yarn": ">=1.21.1 <2",
"npm": "Please use yarn instead of NPM to install dependencies"
},
Expand Down
12 changes: 7 additions & 5 deletions packages/angular/cli/bin/ng.js
Expand Up @@ -24,8 +24,8 @@ 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.
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+)
if (version[0] % 2 === 1 && version[0] > 16) {
// Allow new odd numbered releases with a warning (currently v17+)
console.warn(
'Node.js version ' +
process.version +
Expand All @@ -38,15 +38,17 @@ if (version[0] % 2 === 1 && version[0] > 14) {
} else if (
version[0] < 12 ||
version[0] === 13 ||
version[0] === 15 ||
(version[0] === 12 && version[1] < 20) ||
(version[0] === 14 && version[1] < 15)
(version[0] === 14 && version[1] < 15) ||
(version[0] === 16 && version[1] < 10)
) {
// Error and exit if less than 12.20 or 13.x or less than 14.15
// Error and exit if less than 12.20 or 13.x or less than 14.15 or 15.x or less than 16.10
console.error(
'Node.js version ' +
process.version +
' detected.\n' +
'The Angular CLI requires a minimum Node.js version of either v12.20 or v14.15.\n\n' +
'The Angular CLI requires a minimum Node.js version of either v12.20, v14.15, or v16.10.\n\n' +
'Please update your Node.js version or visit https://nodejs.org/ for additional instructions.\n',
);

Expand Down
2 changes: 1 addition & 1 deletion packages/angular/cli/commands/version-impl.ts
Expand Up @@ -16,7 +16,7 @@ import { Schema as VersionCommandSchema } from './version';
/**
* Major versions of Node.js that are officially supported by Angular.
*/
const SUPPORTED_NODE_MAJORS = [12, 14];
const SUPPORTED_NODE_MAJORS = [12, 14, 16];

interface PartialPackageInfo {
name: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/angular/cli/lib/cli/index.ts
Expand Up @@ -23,10 +23,10 @@ const isDebug = debugEnv !== undefined && debugEnv !== '0' && debugEnv.toLowerCa
export default async function (options: { testing?: boolean; cliArgs: string[] }) {
// This node version check ensures that the requirements of the project instance of the CLI are met
const version = process.versions.node.split('.').map((part) => Number(part));
if (version[0] < 12 || (version[0] === 12 && version[1] < 14)) {
if (version[0] < 12 || (version[0] === 12 && version[1] < 20)) {
process.stderr.write(
`Node.js version ${process.version} detected.\n` +
'The Angular CLI requires a minimum v12.14.\n\n' +
'The Angular CLI requires a minimum v12.20.\n\n' +
'Please update your Node.js version or visit https://nodejs.org/ for additional instructions.\n',
);

Expand Down
3 changes: 2 additions & 1 deletion tests/legacy-cli/e2e/tests/commands/add/version-specifier.ts
Expand Up @@ -22,7 +22,8 @@ export default async function () {
throw new Error('Installation should not have been skipped');
}

const output3 = await ng('add', '@angular/localize@12.0.0', '--skip-confirmation');
// v12.2.0 has a package.json engine field that supports Node.js v16+
const output3 = await ng('add', '@angular/localize@12.2.0', '--skip-confirmation');
if (output3.stdout.includes('Skipping installation: Package already installed')) {
throw new Error('Installation should not have been skipped');
}
Expand Down

0 comments on commit 9fe5575

Please sign in to comment.