DEV Community

loading...

Discussion on: PWAs with Angular: Being Reliable

Collapse
stephaneeybert profile image
Stephane Eybert • Edited

My experience running this tutorial:

I had to install some missing dependencies:
npm install -g reflect-metadata
npm install -s @angular/cdk

I also upgraded the cli:
npm install -s @angular/cli@latest

I checked for updates:
npm-check-updates -u

To run the ngu-sw-manifest I had to use the npm-run utility:
npm-run ngu-sw-manifest --module src/app/app.module.ts

I finally hit a road block:
$ npm-run ngu-sw-manifest --module src/app/app.module.ts --out dist/ngsw-manifest.json

/home/stephane/dev/js/projects/angular/ng-popular-movies-pwa/node_modules/ng-pwa-tools/lib/sw-manifest/index.js:34
manifest = JSON.parse(fs.readFileSync(args.manifest).toString());
^
SyntaxError: Unexpected token / in JSON at position 148
at JSON.parse ()
at Object.generateSwManifest (/home/stephane/dev/js/projects/angular/ng-popular-movies-pwa/node_modules/ng-pwa-tools/lib/sw-manifest/index.js:34:25)
at Object. (/home/stephane/dev/js/projects/angular/ng-popular-movies-pwa/node_modules/ng-pwa-tools/bin/ngu-sw-manifest.js:18:15)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Function.Module.runMain (module.js:605:10)
at Object. (/home/stephane/dev/js/projects/angular/ng-popular-movies-pwa/node_modules/ts-node/src/_bin.ts:177:12)

Collapse
michaelsolati profile image
Michael Solati Author

I just updated the tags and codebase on GitHub, it should be all set to go.

Collapse
stephaneeybert profile image
Stephane Eybert

Thank you for the update. I git cloned it again then, but ended up in the ditch again.

$ npm-run ngu-sw-manifest --module src/app/app.module.ts
/usr/bin/env: «node_modules/.bin/ts-node»: Aucun fichier ou dossier de ce type

Sorry for being an PWA noob.

Thread Thread
michaelsolati profile image
Michael Solati Author

Are you on Windows? Also the following command should work... ./node_modules/.bin/ngu-sw-manifest --module src/app/app.module.ts

Thread Thread
stephaneeybert profile image
Stephane Eybert

I'm on Linux, a 30 year man. I first coded on our Atari 800XL in 1984. I did use Windows at times though, on some contract jobs.

I get the same response with your command:
$ ./node_modules/.bin/ngu-sw-manifest --module src/app/app.module.ts
/usr/bin/env: «node_modules/.bin/ts-node»: Aucun fichier ou dossier de ce type
[stephane@stephane-ThinkPad-X201 ng-popular-movies-pwa ((v0.0))]
$ npm-run ngu-sw-manifest --module src/app/app.module.ts
/usr/bin/env: «node_modules/.bin/ts-node»: Aucun fichier ou dossier de ce type

I feel like this issue of mine is not related to the actual content of your tutorial, and thus don't want to bother you with it. I shall post on SO if that is of interest to the Javascript Angular crowd.

Thread Thread
michaelsolati profile image
Michael Solati Author

Haha, ok, well I have one more idea... node ./node_modules/.bin/ngu-sw-manifest --module src/app/app.module.ts

Thread Thread
stephaneeybert profile image
Stephane Eybert

I posted on SO so as not to hijack your comments thread here.

stackoverflow.com/questions/455714...

Collapse
michaelsolati profile image
Michael Solati Author

There have been some changes to the @angular/material where @angular/cdk has been broken out and needs to be installed separately as you said. Also there is an issue with lazy loading with the latest CLI building which requires the installation of enhanced-resolve you can see here.

In regards to the service worker stuff I would need to see your code before I can say anything for sure.