Skip to content

Error on ng add @angular/pwa #10469

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
StephenFluin opened this issue Apr 26, 2018 · 15 comments · Fixed by angular/devkit#813
Closed

Error on ng add @angular/pwa #10469

StephenFluin opened this issue Apr 26, 2018 · 15 comments · Fixed by angular/devkit#813

Comments

@StephenFluin
Copy link
Contributor

Versions

Angular CLI: 6.0.0-rc.6
Node: 9.2.0
OS: linux x64
Angular: 6.0.0-rc.5
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.5.6
@angular-devkit/build-angular     0.5.6
@angular-devkit/build-optimizer   0.5.6
@angular-devkit/core              0.5.6
@angular-devkit/schematics        0.5.8
@angular/cli                      6.0.0-rc.6
@angular/pwa                      0.5.8
@ngtools/json-schema              1.1.0
@ngtools/webpack                  6.0.0-rc.4
@schematics/angular               0.5.8
@schematics/update                0.5.8
rxjs                              6.0.0
typescript                        2.7.2
webpack                           4.5.0

Repro steps

ng new my-app
cd my-app
ng add @angular/pwa

Observed behavior

$ ng add @angular/pwa
Installing packages for tooling via npm.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ @angular/[email protected]
added 70 packages and removed 4 packages in 6.842s
Installed packages for tooling via npm.
Schematic input does not validate against the Schema: {"help":false,"h":false,"target":"build","configuration":"production"}
Errors:

  Data path "" should have required property 'project'.

Desired behavior

Add PWA super powers to my app

@yankedev
Copy link

I have the same-same error with:

Angular CLI: 6.0.0-rc.6
Node: 8.11.1
OS: darwin x64
Angular: 6.0.0-rc.5
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.5.9
@angular-devkit/build-angular     0.5.9
@angular-devkit/build-optimizer   0.5.9
@angular-devkit/core              0.5.9
@angular-devkit/schematics        0.5.8
@angular/cli                      6.0.0-rc.6
@angular/pwa                      0.5.9
@ngtools/json-schema              1.1.0
@ngtools/webpack                  6.0.0-rc.7
@schematics/angular               0.5.8
@schematics/update                0.5.8
rxjs                              6.0.0
typescript                        2.7.2
webpack                           4.6.0

@rfk91
Copy link

rfk91 commented Apr 27, 2018

The following worked for me
ng add @angular/pwa --project myprojectname

@yankedev
Copy link

thanks! this fixed my problem :-)

since I'm adding something to an existing project, could --project be optional and take current project as the default?

@cyrilletuzi
Copy link
Contributor

#10486 and angular/devkit#764 should enable this, but both ng add @angular/pwa and ng g service-worker still have their project property set as required in angular/devkit.

I tried to do the PR but I'm not sure there is just to mark project as optional (devkit tests have to explicitly set the project option, so I can't verify it's working without it).

@cyrilletuzi
Copy link
Contributor

PR in angular/devkit#813

@collindutter
Copy link

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?

@Rumsha001
Copy link

@collindutter your angular-cli.json file should be updated to angular.json
Your build options should look like this attachment.
image

@Rumsha001
Copy link

find your correct project name in angular.json file under projects.

@maeri
Copy link

maeri commented Jun 22, 2018

@collindutter hey - by any chance any update on this ?

@collindutter
Copy link

@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!

@maeri
Copy link

maeri commented Jun 22, 2018

@collindutter wow it works !! thank you very much :)

@ssi-hu-tasi-norbert
Copy link

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

@sjohnson32
Copy link

Same here. I get the same error as ssi-hu-tasi-norbert with or without defining the project name.
ng add @angular/[email protected] --project myprojectname

@rlipka
Copy link

rlipka commented Sep 13, 2018

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?

Did you have a solution for "Cannot read property 'options' of undefined"?

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants