You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[BUG] SyntaxError: JSON5: invalid character '.' at 1:470 #1124
Error during generation of routes JSON file, maybe a trailing comma or an external variable inside one route.
Unhandled Rejection at: Promise {
SyntaxError: JSON5: invalid character '.' at 1:470
at syntaxError (/Users/project/node_modules/json5/lib/parse.js:1083:17)
at invalidChar (/Users/project/node_modules/json5/lib/parse.js:1028:12)
at Object.afterArrayValue (/Users/project/node_modules/json5/lib/parse.js:672:15)
at Object.default (/Users/project/node_modules/json5/lib/parse.js:146:37)
at lex (/Users/project/node_modules/json5/lib/parse.js:78:42)
at Object.parse (/Users/project/node_modules/json5/lib/parse.js:25:17)
at loopModulesParser (/Users/project/node_modules/@compodoc/compodoc/dist/index-cli-32a621dc.js:5711:51)
at RouterParserUtil.constructRoutesTree (/Users/project/node_modules/@compodoc/compodoc/dist/index-cli-32a621dc.js:5736:13)
at AngularDependencies.getDependencies (/Users/project/node_modules/@compodoc/compodoc/dist/index-cli-32a621dc.js:8673:50)
at CliApplication.Application.getDependenciesData (/Users/project/node_modules/@compodoc/compodoc/dist/index-cli-32a621dc.js:10227:40) {
lineNumber: 1,
columnNumber: 470
}
}
changed the title [-]SyntaxError: JSON5: invalid character '.' at 1:470[/-][+][BUG] SyntaxError: JSON5: invalid character '.' at 1:470[/+]on Dec 29, 2021
How I unblocked myself with regards to this error:
I ctrl + clicked on the parse.js:1083:17 error in the terminal (in VS Code, it should open up the file) and I was presented with a function that's similar to this:
I added the console.log (shown in picture) of line, column, parseState, stack, pos, token, key and root, saved the file, and re-ran the command. For me the root property gave me a hint as to which one of my files was causing the issue. It turns out I was using spread syntax (...) in route configuration file and although Angular was not complaining about it, compodoc did not like it. I rewrote the spread syntax into something else and compodoc was satisfied with that and the error did not appear anymore.
Unless if I missed it, I think it would be good if Compodoc can show in red bold text which file was scanned and caused the error.
Reacted by admir86, Bjarte Skjørestad, Nathanrs15, EladBox, Tiago Wanke Marques, Emeka Elo-Chukwuma and Mlipho
Reacted by Divyesh
Reacted by Alchemy86, fLukk3 and Anton G. Neuhold Jr.
I am going off of memory but I am pretty sure it was like so. I just attached the respective canActivate and canLoad for every entry and removed the map to fix it.
The code might not be formatted the best (final display) but I formatted it well in my comment. We are using compodoc ^1.1.11.
Edit: I was able to reproduce it with the following.
It seems to be something to do with the "..." notation that is causing trouble, in my case at least :) I want to use on a big project and can only use the minimal use of compodoc, which is helpful but not that much.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
How I unblocked myself with regards to this error:
I ctrl + clicked on the parse.js:1083:17 error in the terminal (in VS Code, it should open up the file) and I was presented with a function that's similar to this:
I added the console.log (shown in picture) of line, column, parseState, stack, pos, token, key and root, saved the file, and re-ran the command. For me the root property gave me a hint as to which one of my files was causing the issue. It turns out I was using spread syntax (...) in route configuration file and although Angular was not complaining about it, compodoc did not like it. I rewrote the spread syntax into something else and compodoc was satisfied with that and the error did not appear anymore.
Unless if I missed it, I think it would be good if Compodoc can show in red bold text which file was scanned and caused the error.
I followed your steps the same way. Added console.log in the parse.js and it pointed out what was causing the problem
You rock
This issue has been automatically closed because it has not had recent activity. Please file a new issue if you are encountering a similar or related problem. Thank you for your contributions.
This is also an issue for me. I can temporarily fix it by removing the '.' within the require statement but I wouldn't consider this a fix because of course I have to change it after every new npm install ...
How I unblocked myself with regards to this error:
I ctrl + clicked on the parse.js:1083:17 error in the terminal (in VS Code, it should open up the file) and I was presented with a function that's similar to this:
I added the console.log (shown in picture) of line, column, parseState, stack, pos, token, key and root, saved the file, and re-ran the command. For me the root property gave me a hint as to which one of my files was causing the issue. It turns out I was using spread syntax (...) in route configuration file and although Angular was not complaining about it, compodoc did not like it. I rewrote the spread syntax into something else and compodoc was satisfied with that and the error did not appear anymore.
Unless if I missed it, I think it would be good if Compodoc can show in red bold text which file was scanned and caused the error.
This worked for me. I found that it complains about a resolver class:
This is also an issue for me. I can temporarily fix it by removing the '.' within the require statement but I wouldn't consider this a fix because of course I have to change it after every new npm install ...
Activity
MysticBlaze085 commentedon Oct 5, 2021
I am currently running into this error which is keeping me from using storybook
[-]SyntaxError: JSON5: invalid character '.' at 1:470[/-][+][BUG] SyntaxError: JSON5: invalid character '.' at 1:470[/+]luizfernando1996 commentedon Feb 16, 2022
+1
raghav-kanwal commentedon Feb 18, 2022
+1. Getting this issue which is blocking me from using Storybook with Angular as well.
AliF50 commentedon Feb 22, 2022
How I unblocked myself with regards to this error:
I ctrl + clicked on the
parse.js:1083:17error in the terminal (in VS Code, it should open up the file) and I was presented with a function that's similar to this:I added the
console.log(shown in picture) of line, column, parseState, stack, pos, token, key and root, saved the file, and re-ran the command. For me therootproperty gave me a hint as to which one of my files was causing the issue. It turns out I was using spread syntax (...) in route configuration file and although Angular was not complaining about it, compodoc did not like it. I rewrote the spread syntax into something else and compodoc was satisfied with that and the error did not appear anymore.Unless if I missed it, I think it would be good if Compodoc can show in red bold text which file was scanned and caused the error.
vogloblinsky commentedon Feb 22, 2022
@AliF50 Do you have an example of your spread syntax please ?
AliF50 commentedon Feb 22, 2022
I think it was something like this:
const routes = [{ path: 'abc', component: ComponentA, }, { path: 'def', loadChildren: async () => (await import('./path/componentB')).ComponentBModule, }].map(route => ({ ...route, ...(route.component && canActivate: [FeatureGuard]), ...(route.loadChildren && canLoad: [FeatureGuard]), }));I am going off of memory but I am pretty sure it was like so. I just attached the respective canActivate and canLoad for every entry and removed the map to fix it.
The code might not be formatted the best (final display) but I formatted it well in my comment. We are using compodoc ^1.1.11.
Edit: I was able to reproduce it with the following.

rasmus-e-christensen commentedon Mar 2, 2022
It seems to be something to do with the "..." notation that is causing trouble, in my case at least :) I want to use on a big project and can only use the minimal use of compodoc, which is helpful but not that much.
syndesis commentedon Mar 10, 2022
I'm seeing it break in a similar way on a route like this:
it dies on the
.inFeatureFlags.FOO_FLAGThis may be related to json5/json5#249
admir86 commentedon Mar 21, 2022
same problem when using
TimeUserEntry.JOB_DESIGNATIONdirect in theuserEntries. UsingTimeUserEntry.JOB_DESIGNATIONvia a const worksstale commentedon Jul 10, 2022
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
divyeshjethwa commentedon Jul 21, 2022
I followed your steps the same way. Added console.log in the parse.js and it pointed out what was causing the problem
You rock
stale commentedon Jul 31, 2022
This issue has been automatically closed because it has not had recent activity. Please file a new issue if you are encountering a similar or related problem. Thank you for your contributions.
spyro2000 commentedon Aug 2, 2022
Still same problem with 1.1.19.
In routes:
Explodes:
Runs:
Did only find that out by debugging the json builder.
ElfenB commentedon Sep 1, 2022
This is also an issue for me. I can temporarily fix it by removing the '.' within the require statement but I wouldn't consider this a fix because of course I have to change it after every new npm install ...
parse.jsterminal output (excerpt)Nathanrs15 commentedon Nov 16, 2022
This worked for me. I found that it complains about a resolver class:
❌ Bad:
{path: 'some-path', resolver: { ResolverClass } ...}👍 Good:
{path: 'some-path', resolver: { name: ResolverClass } ...}ivanFlor3s commentedon Apr 26, 2023
It solved my problem when generating documentation
enrosales commentedon May 24, 2023
in my case doing this and setting clg() in the syntaxError function fix the problem
markwhitfeld commentedon Jun 25, 2025
@AliF50's approach of adding the console log helped me identify the issue.
For anyone that would like to copy paste the console log, here it is: