Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ionic context.getProjectMetadata is not a function [Live Reload only]

I'm facing an issue with ionic live reload failing to build due to the error "context.getProjectMetaData is not a function" I am just encountering this issue after installing the Firebase cloud messaging cordova plugin and npm package (for push notifications). Im unsure if this would the issue as the app build and launches without live reload. (and fcm works properly)

This is the error log im getting, anyone experienced this before?

[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)


like image 507
Hunt3R Avatar asked Mar 18 '20 19:03

Hunt3R


2 Answers

I started having this problem after I ran npm audit fix because I wanted to have a project that's clean of vulnerabilities.

It seems, npm audit fix command is rather greedy. It silently upgraded my "@angular-devkit/build-angular": "~0.803.25" to version 0.9, thus breaking my Angular 8 app with the same context.getProjectMetadata is not a function error.

Morale of the story - be very careful with npm audit fix and inspect what it does to your package.json.

like image 175
JustAMartin Avatar answered Nov 15 '22 03:11

JustAMartin


I was facing this same issue when updating from angular 8 to 9, what fixed it for me was:

npm install @angular-devkit/architect@latest
npm install @angular-devkit/build-angular@latest

Found original solution at https://github.com/ionic-team/angular-toolkit/issues/215#issuecomment-612616498

like image 29
Camilo Casadiego Avatar answered Nov 15 '22 04:11

Camilo Casadiego