angular-cli: Error: Unexpected end of file
Bug Report or Feature Request (mark with an x
)
- [x] bug report
- [ ] feature request
Area
- [x] devkit
- [ ] schematics
Versions
node --version
v10.3.0
npm --version
6.1.0
sw_vers
ProductName: Mac OS X
ProductVersion: 10.12.6
BuildVersion: 16G1314
Repro steps
npm uninstall -g @angular/cli
npm cache verify
npm install -g @angular/cli
ng version
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 6.0.8
Node: 10.3.0
OS: darwin x64
Angular:
...
Package Version
------------------------------------------------------
@angular-devkit/architect 0.6.8
@angular-devkit/core 0.6.8
@angular-devkit/schematics 0.6.8
@schematics/angular 0.6.8
@schematics/update 0.6.8
rxjs 6.2.0
typescript 2.7.2
ng new foo ✘ 141
The log given by the failure
Unexpected end of file.
Error: Unexpected end of file.
at _readValue (/usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/core/src/json/parser.js:533:19)
at parseJsonAst (/usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/core/src/json/parser.js:605:17)
at Object.parseJson (/usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/core/src/json/parser.js:631:12)
at getLegacyPackageManager (/usr/local/lib/node_modules/@angular/cli/utilities/config.js:179:35)
at Object.getPackageManager (/usr/local/lib/node_modules/@angular/cli/utilities/config.js:120:38)
at NewCommand.runSchematic (/usr/local/lib/node_modules/@angular/cli/models/schematic-command.js:74:38)
at NewCommand.<anonymous> (/usr/local/lib/node_modules/@angular/cli/commands/new.js:77:25)
at Generator.next (<anonymous>)
at /usr/local/lib/node_modules/@angular/cli/commands/new.js:7:71
at new Promise (<anonymous>)
Desired functionality
Properly recovered from or better error message caused by bad data in user files.
The cause was that ~/.angular-cli.json
was an empty file.
Mention any other details that might be useful
I track down the error using
node --inspect --debug-brk /usr/local/bin/ng new foo
with a break-point in /usr/local/lib/node_modules/@angular/cli/node_modules/@angular-devkit/core/src/json/parser.js
just before UnexpectedEndOfInputException
call super("Unexpected end of file.")
then I realize that this file const legacyGlobalConfigPath = path.join(homeDir, '.angular-cli.json')
was used and when I take a look it was empty, so the error is consistent with a bad json parsing, but at least will be good if we had the filename in the error
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 8
- Comments: 17 (6 by maintainers)
Often this is caused by a syntax error in
angular.json
angular 9 to angular 10 upgrade.I tried both node versions 10.17 and 12.18, operating system ubuntu 18.04.4 it happens with the typescript migration step
Add "Solution Style" TypeScript configuration file support. This improves developer experience using editors powered by TypeScript’s language server. Read more about this here: https://v10.angular.io/guide/migration-solution-style-tsconfig ✖ Migration failed: Unexpected end of file. See "/tmp/ng-j7kG46/angular-errors.log" for further details.
[error] Error: Unexpected end of file. at _readValue (/tmp/angular-cli-packages-OQomyr/node_modules/@angular-devkit/core/src/json/parser.js:625:19) at Object.parseJsonAst (/tmp/angular-cli-packages-OQomyr/node_modules/@angular-devkit/core/src/json/parser.js:722:17) at visitExtendedJsonFiles (/tmp/angular-cli-packages-OQomyr/node_modules/@schematics/angular/migrations/update-10/solution-style-tsconfig.js:30:32) at visitExtendedJsonFiles.next (<anonymous>) at visitExtendedJsonFiles (/tmp/angular-cli-packages-OQomyr/node_modules/@schematics/angular/migrations/update-10/solution-style-tsconfig.js:45:16) at visitExtendedJsonFiles.next (<anonymous>) at visitExtendedJsonFiles (/tmp/angular-cli-packages-OQomyr/node_modules/@schematics/angular/migrations/update-10/solution-style-tsconfig.js:45:16) at visitExtendedJsonFiles.next (<anonymous>) at visitExtendedJsonFiles (/tmp/angular-cli-packages-OQomyr/node_modules/@schematics/angular/migrations/update-10/solution-style-tsconfig.js:45:16) at visitExtendedJsonFiles.next (<anonymous>) at visitExtendedJsonFiles (/tmp/angular-cli-packages-OQomyr/node_modules/@schematics/angular/migrations/update-10/solution-style-tsconfig.js:45:16) at visitExtendedJsonFiles.next (<anonymous>) at visitExtendedJsonFiles (/tmp/angular-cli-packages-OQomyr/node_modules/@schematics/angular/migrations/update-10/solution-style-tsconfig.js:45:16) at visitExtendedJsonFiles.next (<anonymous>) at host (/tmp/angular-cli-packages-OQomyr/node_modules/@schematics/angular/migrations/update-10/solution-style-tsconfig.js:56:45) at MergeMapSubscriber.pipe.operators_1.mergeMap.inputTree [as project] (/tmp/angular-cli-packages-OQomyr/node_modules/@angular-devkit/schematics/src/rules/call.js:75:24)
UPDATE To overcome this problem I made this step manually 1- by renaming tsconfig.json to tsconfig.base.json 2- I added tsconfig.json, tsconfig.app.json and tsconfig.spec.json but after this fix I am facing another problem with the new tsconfig.json file
Could not resolve module '@angular/core' relative to file undefined
when I use the old one without the “files array” everything works@SchnWalter : I got the obscur error while running ng update, not ng serve. But I was on unhappy path, because I cleared my proxy conf after running ng serve. That should probably never happen …
I’ll try it another time to be sure
when I upgrade angular-cli version from 1.6.6 to 9, I got this issue also