Solvedangular cli Error on ng add @angular/pwa
✔️Accepted Answer
The following worked for me
ng add @angular/pwa --project myprojectname
Other Answers:
@maeri yes, actually! In this file on line 137, it iterates over a list of strings, and does some work on them.
['build', 'test'].forEach((target) => {
const applyTo = architect[target].options;
if (!applyTo.assets) {
applyTo.assets = [assetEntry];
} else {
applyTo.assets.push(assetEntry);
}
});
In my angular.json, I had a 'build' section, but I had removed the 'test' section because I didn't need it for my current project. So when it evaluated architect['test'].options
it threw the error you're seeing.
Not sure if this is the case for everyone, but it directly fixed it for me. Hope this helps!
I'm trying to run the command ng add @angular/pwa --project myprojectname
and I'm getting the following error: Cannot read property 'options' of undefined
. Has anyone else seen this?
It is still an issue
Angular CLI: 6.1.1
Node: 8.11.3
OS: win32 x64
Angular: 6.1.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
Package Version
@angular-devkit/architect 0.7.1
@angular-devkit/build-angular 0.7.1
@angular-devkit/build-optimizer 0.7.1
@angular-devkit/build-webpack 0.7.1
@angular-devkit/core 0.7.1
@angular-devkit/schematics 0.7.1
@angular/cli 6.1.1
@angular/pwa 0.6.8
@ngtools/webpack 6.1.1
@schematics/angular 0.7.1
@schematics/update 0.7.1
rxjs 6.2.2 (cli-only)
typescript 2.9.2
webpack 4.9.2
Schematic input does not validate against the Schema: {"project":"pmt","target":"build","configuration":"production","title":"pmt"}
Errors:
Data path "" should NOT have additional properties(title).
And adding --service-worker to generate a new project also fails.
c:\development>ng new pmt --style=scss --service-worker
Schematic input does not validate against the Schema: {"style":"scss","serviceWorker":true,"version":"6.1.1","skipGit":false,"skipInstall":false,"linkCli":false,"commit":true,"newProjectRoot":"projects","inlineStyle":false,"inlineTemplate":false,"routing":false,"prefix":"app","skipTests":false}
Errors:
Data path "" should NOT have additional properties(serviceWorker).
Versions
Repro steps
ng new my-app
cd my-app
ng add @angular/pwa
Observed behavior
Desired behavior
Add PWA super powers to my app