1

I am new to coding, and I want to start using Angular on my M1 MacBook.

The installation of Angular cli was only somewhat successful, as I got this warning after typing sudo npm install -g @angular/cli:

npm WARN deprecated @npmcli/move-file@2.0.1: This functionality has been moved to @npmcli/fs

...But angular must be installed, since I get this message after typing ng v:

❯ ng v

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 15.1.5
Node: 18.14.0
Package Manager: npm 9.3.1
OS: darwin arm64

Angular: undefined
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.1501.5 (cli-only)
@angular-devkit/core         15.1.5 (cli-only)
@angular-devkit/schematics   15.1.5 (cli-only)
@schematics/angular          15.1.5 (cli-only)

But when I type ng new Hello-World into terminal to create a new project, I get this error message:

⠴ Installing packages (npm)...npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: hello-world@0.0.0
npm ERR! Found: rxjs@undefined
npm ERR! node_modules/rxjs
npm ERR!   rxjs@"~7.8.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer rxjs@"^6.5.3 || ^7.4.0" from @angular/core@15.1.4
npm ERR! node_modules/@angular/core
npm ERR!   @angular/core@"^15.1.0" from the root project
npm ERR!   peer @angular/core@"15.1.4" from @angular/animations@15.1.4
npm ERR!   node_modules/@angular/animations
npm ERR!     @angular/animations@"^15.1.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! For a full report see:
npm ERR! /Users/cez/.npm/_logs/2023-02-15T12_35_49_149Z-eresolve-report.txt

As I understand it, the problem is that my rxjs version is ~7.8.0 (which can be confirmed by looking in the package.json file), and 7.8.0 is not between ^6.5.3 || ^7.4.0, and therefore too new. But how do I solve this?

Here are some potentially relevant versions of what I have installed.

❯ node --version
v18.14.0
❯ npm --version
9.3.1

I hope someone can help me fix the issue.

I have tried running ng new Hello-World --force as the error message suggests. I got this message:

⠧ Installing packages (npm)...npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: hello-world@0.0.0
npm ERR! Found: rxjs@undefined
npm ERR! node_modules/rxjs
npm ERR!   rxjs@"~7.8.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer rxjs@"^6.5.3 || ^7.4.0" from @angular/core@15.1.4
npm ERR! node_modules/@angular/core
npm ERR!   @angular/core@"^15.1.0" from the root project
npm ERR!   peer @angular/core@"15.1.4" from @angular/animations@15.1.4
npm ERR!   node_modules/@angular/animations
npm ERR!     @angular/animations@"^15.1.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR!
npm ERR! For a full report see:
npm ERR! /Users/cez/.npm/_logs/2023-02-15T12_55_47_782Z-eresolve-report.txt

I also tried running ng new Hello-World --legacy-peer-deps without any results It gave me this message:

Error: Unknown argument: legacy-peer-deps

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
  • Were you forced to use sudo by the OS when installing angular? Since you are installing it globally with the -g flag it may encounter issues when trying to access dependencies with your regular user. `--legacy-peer-deps` is an npm flag so that is why the angular cli is telling you it is an unknown argument. Another thing you could try is to install the failing dependencies with the target version you want, for instance `npm i -g rxjs@7.4.0` (previous removal of the currently installed version) – Jordi Riera Feb 17 '23 at 00:11

0 Answers0