manfredsteyer / ngx-build-plus

Extend the Angular CLI's default build behavior without ejecting, e. g. for Angular Elements
1.19k stars 136 forks source link

ng serve doesn't work with Angular 9 #164

Open niklissad opened 4 years ago

niklissad commented 4 years ago

using "serve": { "builder": "ngx-build-plus:dev-server" ... }

cause An unhandled exception occurred: context.getProjectMetadata is not a function

manfredsteyer commented 4 years ago

If you run ng version, do you see some old dependencies (version 8 or 0.800)? If yes, updating them to ^9 or ~0.900 manually via npm install xyz@version should do the job.

Can you confirm, this helped in your case?

niklissad commented 4 years ago
    "@angular-devkit/build-angular": "~0.900.1",
    "@angular-devkit/build-ng-packagr": "~0.900.1",
    "@angular/cli": "9.0.1",
    "@angular/compiler-cli": "^9.0.0",
    "@angular/language-service": "^9.0.0",
    "ngx-build-plus": "^9.0.4",

my dependencies looks updated

niklissad commented 4 years ago

found detailed log

[error] TypeError: context.getProjectMetadata is not a function
    at Object.configureI18nBuild (.../node_modules/@angular-devkit/build-angular/src/utils/i18n-options.js:99:36)
    at Object.generateI18nBrowserWebpackConfigFromContext (.../node_modules/@angular-devkit/build-angular/src/utils/webpack-browser-config.js:85:57)
    at Object.buildBrowserWebpackConfigFromContext (.../node_modules/@angular-devkit/build-angular/src/browser/index.js:67:41)
    at setup (.../node_modules/@angular-devkit/build-angular/src/dev-server/index.js:103:63)
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)⏎

with this "builder": "@angular-devkit/build-angular:dev-server" all is ok

maxime1992 commented 4 years ago

Just faced this error and it drove me mad for a while. Finally found the solution:

If most of your angular dependencies are 9.0.1 but some of them are 9.0.2 or 0.900.2, change all the 2 with 1... for ex:

"@angular/cli": "9.0.2", --> "@angular/cli": "9.0.1",

"@angular-devkit/build-angular": "0.900.2", --> "@angular-devkit/build-angular": "0.900.1",

etc

jwright04 commented 4 years ago

I'm still noticing the same error with the latest version (9.0.6). I followed @niklissad suggestion and reverted the "builder" property to use @angular-devkit and it's building properly.

Siedlerchr commented 4 years ago

I could fix it by installing/updating the following dev dependencies: (for angular 9.1) with "ngx-build-plus": "^9.0.6",

npm i --save-dev "

 "@angular-devkit/architect": "~0.900.1",
 "@angular-devkit/build-angular": "^0.900.7",
vdshb commented 4 years ago

I've faced the same problem. Looks like a bug in @ionic/angular-toolkit


"@angular/common": "^9.1.1",
"@angular/core": "^9.1.1",
"@angular/forms": "^9.1.1",
"@angular/platform-browser": "^9.1.1",
"@angular/platform-browser-dynamic": "^9.1.1",
"@angular/router": "^9.1.1",
"@ionic-native/core": "^5.22.0",
"@ionic-native/splash-screen": "^5.22.0",
"@ionic-native/status-bar": "^5.22.0",
"@ionic/angular": "^5.0.7",

"@angular-devkit/architect": "^0.802.2",
"@angular-devkit/build-angular": "~0.901.1",
"@angular-devkit/core": "^9.1.1",
"@angular-devkit/schematics": "^9.1.1",
"@angular/cli": "^9.1.1",
"@angular/compiler": "^9.1.1",
"@angular/compiler-cli": "^9.1.1",
"@angular/language-service": "^9.1.1",
"@ionic/angular-toolkit": "^2.2.0",

"ionic-cordova-build": {
      "builder": "@ionic/angular-toolkit:cordova-build",
      "options": {
        "browserTarget": "app:build"
      },
      "configurations": {
        "production": {
          "browserTarget": "app:build:production"
        }
      }
    },
n3w0rld94 commented 4 years ago

Had the same problem, these fixed it:

ng update

Gave me a list of deps I had to update, ran the first one:

ng update @angular/cli

and it fixed everything by itself, updating the project too