Skip to content

ng update - Migration failed: Unexpected token '', "{ "nam"... is not valid JSON #27052

@dapperdandev

Description

@dapperdandev

Command

update

Is this a regression?

  • Yes, this behavior used to work in the previous version

The previous version in which this bug was not present was

Unsure

Description

ng update @angular/core fails from v17.0.8 to latest

Minimal Reproduction

Attempt ng update @angular/core from a project on 17.0.8

Exception or Error

with the message: Using package manager: npm Collecting installed dependencies... Found 126 dependencies. Fetching dependency metadata from registry... × Migration failed: Unexpected token '', "{ "nam"... is not valid JSON See "C:\Users\danin\AppData\Local\Temp\ng-ckaJxh\angular-errors.log" for further details. 

From log file:

[error] SyntaxError: Unexpected token '', "{ "nam"... is not valid JSON at JSON.parse (<anonymous>) at _buildPackageInfo (C:\Users\danin\AppData\Roaming\fnm\node-versions\v20.9.0\installation\node_modules\@angular\cli\src\commands\update\schematic\index.js:429:30) at C:\Users\danin\AppData\Roaming\fnm\node-versions\v20.9.0\installation\node_modules\@angular\cli\src\commands\update\schematic\index.js:708:53 at Map.forEach (<anonymous>) at C:\Users\danin\AppData\Roaming\fnm\node-versions\v20.9.0\installation\node_modules\@angular\cli\src\commands\update\schematic\index.js:707:27 at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async callRuleAsync (C:\Users\danin\AppData\Roaming\fnm\node-versions\v20.9.0\installation\node_modules\@angular\cli\node_modules\@angular-devkit\schematics\src\rules\call.js:77:18) 

Your Environment

CLI: 17.1.2 Node: 20.9.0 Package Manager: npm 10.1.0 OS: win32 x64 Angular: 17.0.8 ... animations, common, compiler, compiler-cli, core, forms ... platform-browser, platform-browser-dynamic, router, upgrade Package Version ------------------------------------------------------ @angular-devkit/architect 0.1701.2 (cli-only) @angular-devkit/core 17.1.2 (cli-only) @angular-devkit/schematics 17.1.2 (cli-only) @ngtools/webpack 17.0.9 @schematics/angular 17.1.2 (cli-only) rxjs 7.8.1 typescript 5.2.2 webpack 5.89.0 zone.js 0.14.2 

Anything else relevant?

The first time I ran the command it seemed to start working. It updated the package.json and logged installing dependencies. I aborted the process with HOST + C. I thought that had potentially partially installed files and quit writing midstream. That would explain the "nam" is not valid JSON message. However, I get the exact same error on two different machines.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions