Tony Brasunas
Tony Brasunas

Reputation: 4602

Upgrading Angular 16 => 17 seeing "Cannot find module '@angular/build/package.json'"

I'm upgrading my app from Angular 16 => 17. Everything going fine, but when I do npm install and then ng serve I get an error:

An unhandled exception occurred: Cannot find module '@angular/build/package.json'

And if I try to install this lib with npm install --save-dev @angular/build I get a different issue -- a dependency issue. @angular/build requires at least Angular 18.

So how can I run my app on v17?

Upvotes: 1

Views: 333

Answers (1)

Tony Brasunas
Tony Brasunas

Reputation: 4602

Check your angular.json settings for the ng serve command. It turns out, my serve was pointed to another stanza called serve-original since I'm using Module Federation and have migrated to Native Federation.

In that stanza make sure you're pointing to the v17-compatible "@angular-devkit/build-angular" and not the newer "@angular/build"

Change:

                "serve-original": {
                    "builder": "@angular/build:dev-server",

to

                "serve-original": {
                    "builder": "@angular-devkit/build-angular:dev-server",

You should be good to go with ng s for your v17 app.

Upvotes: 0

Related Questions