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

feat(@angular/cli): add support for Node.js version 18 #24026

Merged
merged 1 commit into from
Oct 7, 2022
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
10 changes: 5 additions & 5 deletions .circleci/dynamic_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ parameters:
# Windows needs its own cache key because binaries in node_modules are different.
# See https://circleci.com/docs/2.0/caching/#restoring-cache for how prefixes work in CircleCI.
var_1: &cache_key v1-angular_devkit-14.20-{{ checksum "yarn.lock" }}
var_1_win: &cache_key_win v1-angular_devkit-win-16.10-{{ checksum "yarn.lock" }}
var_1_win: &cache_key_win v1-angular_devkit-win-16.13-{{ checksum "yarn.lock" }}
var_3: &default_nodeversion '14.20'
var_3_major: &default_nodeversion_major '14'
# The major version of node toolchains. See tools/toolchain_info.bzl
Expand Down Expand Up @@ -114,8 +114,8 @@ commands:
setup_windows:
steps:
- initialize_env
- run: nvm install 16.10
- run: nvm use 16.10
- run: nvm install 16.13
- run: nvm use 16.13
- run: npm install -g yarn@1.22.10
- run: node --version
- run: yarn --version
Expand Down Expand Up @@ -421,15 +421,15 @@ workflows:
matrix:
alias: e2e-cli
parameters:
nodeversion: ['14.20', '16.10']
nodeversion: ['14.20', '16.13', '18.10']
subset: *all_e2e_subsets
requires:
- build
<<: *only_release_branches

- e2e-tests:
name: e2e-snapshots-<< matrix.subset >>
nodeversion: '16.10'
nodeversion: '16.13'
matrix:
parameters:
subset: *all_e2e_subsets
Expand Down
2 changes: 1 addition & 1 deletion constants.bzl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Engine versions to stamp in a release package.json
RELEASE_ENGINES_NODE = "^14.20.0 || >=16.10.0"
RELEASE_ENGINES_NODE = "^14.20.0 || ^16.13.0 || >=18.10.0"
RELEASE_ENGINES_NPM = "^6.11.0 || ^7.5.6 || >=8.0.0"
RELEASE_ENGINES_YARN = ">= 1.13.0"

Expand Down
2 changes: 1 addition & 1 deletion docs/DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ To get started locally, follow these instructions:

1. If you haven't done it already, [make a fork of this repo](https://github.com/angular/angular-cli/fork).
1. Clone to your local computer using `git`.
1. Make sure that you have Node `v14.20`, or `v16.10` installed. See instructions [here](https://nodejs.org/en/download/).
1. Make sure that you have Node `v14.20`, `v16.13` or `v18.10` installed. See instructions [here](https://nodejs.org/en/download/).
1. Make sure that you have `yarn` installed; see instructions [here](https://yarnpkg.com/lang/en/docs/install/).
1. Run `yarn` (no arguments) from the root of your clone of this project to install dependencies.

Expand Down
2 changes: 1 addition & 1 deletion lib/packages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ function loadPackageJson(p: string) {
// Overwrite engines to a common default.
case 'engines':
pkg['engines'] = {
'node': '^14.20.0 || >=16.10.0',
'node': '^14.20.0 || ^16.13.0 || >=18.10.0',
'npm': '^6.11.0 || ^7.5.6 || >=8.0.0',
'yarn': '>= 1.13.0',
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"url": "https://github.com/angular/angular-cli.git"
},
"engines": {
"node": "^14.20.0 || ^16.10.0",
"node": "^14.20.0 || ^16.13.0 || ^18.10.0",
"yarn": ">=1.21.1 <2",
"npm": "Please use yarn instead of NPM to install dependencies"
},
Expand Down
12 changes: 6 additions & 6 deletions packages/angular/cli/bin/ng.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ 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] > 16) {
if (version[0] % 2 === 1) {
// Allow new odd numbered releases with a warning (currently v17+)
console.warn(
'Node.js version ' +
Expand All @@ -37,16 +37,16 @@ if (version[0] % 2 === 1 && version[0] > 16) {
require('./bootstrap');
} else if (
version[0] < 14 ||
version[0] === 15 ||
(version[0] === 14 && version[1] < 15) ||
(version[0] === 16 && version[1] < 10)
(version[0] === 14 && version[1] < 20) ||
(version[0] === 16 && version[1] < 13) ||
(version[0] === 18 && version[1] < 10)
) {
// Error and exit if less than 14.20 or 15.x or less than 16.10
// Error and exit if less than 14.20, 16.13 or 18.10
console.error(
'Node.js version ' +
process.version +
' detected.\n' +
'The Angular CLI requires a minimum Node.js version of either v14.20, or v16.10.\n\n' +
'The Angular CLI requires a minimum Node.js version of either v14.20, v16.13 or v18.10.\n\n' +
'Please update your Node.js version or visit https://nodejs.org/ for additional instructions.\n',
);

Expand Down
4 changes: 2 additions & 2 deletions packages/angular/cli/src/commands/version/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface PartialPackageInfo {
/**
* Major versions of Node.js that are officially supported by Angular.
*/
const SUPPORTED_NODE_MAJORS = [14, 16];
const SUPPORTED_NODE_MAJORS = [14, 16, 18];

const PACKAGE_PATTERNS = [
/^@angular\/.*/,
Expand Down Expand Up @@ -118,7 +118,7 @@ export class VersionCommandModule extends CommandModule implements CommandModule
`
Angular CLI: ${ngCliVersion}
Node: ${process.versions.node}${unsupportedNodeVersion ? ' (Unsupported)' : ''}
Package Manager: ${packageManager.name} ${packageManager.version ?? '<error>'}
Package Manager: ${packageManager.name} ${packageManager.version ?? '<error>'}
OS: ${process.platform} ${process.arch}

Angular: ${angularCoreVersion}
Expand Down
2 changes: 1 addition & 1 deletion tools/test/expected_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
}
},
"engines": {
"node": "^14.20.0 || >=16.10.0",
"node": "^14.20.0 || ^16.13.0 || >=18.10.0",
"npm": "^6.11.0 || ^7.5.6 || >=8.0.0",
"yarn": ">= 1.13.0"
}
Expand Down