ng add @angular/pwa --project test-project failed to update package.json when application is under projects folder
See original GitHub issueBug Report or Feature Request (mark with an x
)
- [x] bug report -> please search issues before submitting
- [ ] feature request
Command (mark with an x
)
- [ ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [x] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc
Versions
npm v6.4.0
Angular CLI: 6.2.1
Node: 9.4.0
OS: darwin x64
Angular: 6.1.7
... animations, common, compiler, compiler-cli, core, elements
... forms, http, language-service, platform-browser
... platform-browser-dynamic, router
Package Version
------------------------------------------------------------
@angular-devkit/architect 0.6.8
@angular-devkit/build-angular 0.6.8
@angular-devkit/build-ng-packagr 0.6.8
@angular-devkit/build-optimizer 0.6.8
@angular-devkit/core 0.6.8
@angular-devkit/schematics 0.8.1
@angular/cdk 6.4.7
@angular/cli 6.2.1
@angular/flex-layout 6.0.0-beta.17
@angular/material 6.4.7
@angular/pwa 0.8.1
@ngtools/json-schema 1.1.0
@ngtools/webpack 6.0.8
@schematics/angular 0.8.1
@schematics/update 0.8.1
ng-packagr 3.0.0
rxjs 6.3.2
typescript 2.9.2
webpack 4.8.3
MacOS High Sierra
Repro steps
ng add @angular/pwa --project test-project
The log given by the failure
npm ERR! file /my-project/package.json
npm ERR! code EJSONPARSE
npm ERR! JSON.parse Failed to parse json
npm ERR! JSON.parse Unexpected token
npm ERR! JSON.parse in JSON at position 1205 while parsing '{
npm ERR! JSON.parse "name": "my-project",
npm ERR! JSON.parse "version": "0.0'
npm ERR! JSON.parse Failed to parse package.json data.
npm ERR! JSON.parse package.json must be actual JSON, not just JavaScript.
Desired functionality
Should update package.json, but it’s throwing the above errors when attempts to update package.json. Looks like it’s inserting “@angular/service-worker”: “^6.1.7”, in between the word “ro uter”
"dependencies": {
"@angular/animations": "^6.1.7",
"@angular/cdk": "^6.4.7",
"@angular/common": "^6.1.7",
"@angular/compiler": "^6.1.7",
"@angular/core": "^6.1.7",
"@angular/elements": "^6.1.7",
"@angular/flex-layout": "^6.0.0-beta.16",
"@angular/forms": "^6.1.7",
"@angular/http": "^6.1.7",
"@angular/material": "^6.4.7",
"@angular/platform-browser": "^6.1.7",
"@angular/platform-browser-dynamic": "^6.1.7",
"@angular/pwa": "^0.8.1",
"@angular/ro
"@angular/service-worker": "^6.1.7",uter": "^6.1.7",
"@webcomponents/custom-elements": "^1.1.2",
"cookies": "^0.7.1",
"core-js": "^2.5.4",
"crypto-js": "^3.1.9-1",
"document-register-element": "1.8.1",
"lodash-es": "^4.17.10",
"material-design-icons": "^3.0.1",
"ng-simple-slideshow": "^1.2.4",
"ngx-cookie-service": "^1.0.10",
"profanity-filter": "^0.2.1",
"require": "^2.4.20",
"rxjs": "^6.3.2",
"rxjs-compat": "^6.2.0",
"simplewebrtc": "^3.0.1",
"webrtc-adapter": "^6.2.1",
"zone.js": "^0.8.26"
},
After running “ng add @angular/pwa --project test-project”
ng -v shows
Angular CLI: 6.2.1
Node: 9.4.0
OS: darwin x64
Angular:
...
Package Version
------------------------------------------------------
@angular-devkit/architect 0.8.1
@angular-devkit/core 0.8.1
@angular-devkit/schematics <error>
@schematics/angular <error>
@schematics/update <error>
rxjs 6.2.2
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Cannot update a project from Angular 13 to 14 - Stack Overflow
I have two suggestions: Suggestion 1: First upgrade the @angular-eslint/schematics package. ng update @angular-eslint/schematics@14.
Read more >Angular CLI - Quick Guide - Tutorialspoint
Here, ng generate command has created a new component in our project TutorialsPoint and added this new component entry in app.module.ts. Angular CLI...
Read more >Failed to Connect Android Device - TestProject Documentation
OS X: Open the Agent's installation folder: "/Applications/TestProject ... If you don't see any device in the list, try to change the USB...
Read more >Getting started with service workers - Angular
To set up the Angular service worker in your project, use the CLI command ng add @angular/pwa . It takes care of configuring...
Read more >Angular CLI update issues: Manually Update your ... - Medium
With our Angular project set up, let's take a look at our package.json file, ... Also, if we run ng serve to start...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@alan-agius4 @playground hi, trying to do that in ionic as it as been mentioned in several places but mine stops at Installed packages for tooling via npm. No files created no changes made only to the package.json file any ideas?
The fix was to first run ‘ng update --all’… twice since the first round has a cryptic error: Invalid rule result: Function(). the second time with no error. running ‘ng add @angular/pwa’ then worked as expected
Thanks to Andrew, found this solution in Q&A of https://www.udemy.com/the-complete-guide-to-angular-2/learn/v4/t/lecture/5401674?start=210