dsvorc41
dsvorc41

Reputation: 55

JSDoc cannot parse config file SyntaxError: Unexpected token :

I am using JSDoc 3.4.3 and I'm trying to run config.json file to create documentation for multiple files. However every time I try to run the following command:

jsdoc -c conf.json

I get this error:

Cannot parse the config file conf.json: SyntaxError: Unexpected token : Exiting JSDoc because an error occurred. See the previous log messages for details.

I even tried copying and pasting the example config file found in official JSDoc documentation http://usejsdoc.org/about-configuring-jsdoc.html

"source": {
"include": [ "myProject/a.js", "myProject/lib", "myProject/_private" ],
"exclude": [ "myProject/lib/ignore.js" ],
"includePattern": ".+\\.js(doc)?$",
"excludePattern": "(^|\\/|\\\\)_"
}

But that gives the same error.

Any ideas on how to fix the issue? Thanks!

Upvotes: 0

Views: 2439

Answers (2)

Jiří
Jiří

Reputation: 525

I had this problem when I tried to feed it valid JSON, but in a file with .js extension. Silly mistake, I create a dynamic object and export it into a static json file before running JSDoc and forget to use .json extension for the created file. It gives Cannot parse the config file [...].js: SyntaxError: Unexpected token ':' which is a really bad error message. Hope it helps someone.

Upvotes: 0

Joey G.
Joey G.

Reputation: 633

I had a similar issue. First, I verified that the file was encoded as UTF-8 via Notepad++. When that didn't work, based on the comment from Andreas, I simply copied and pasted my config code into the same file, saved, ran jsdoc -c jsdoc.conf and it worked. Hope this helps someone in the future.

Upvotes: 0

Related Questions