Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: with option -c config file ends with .cjs is still treated as JSON #2105

Open
nyngwang opened this issue Feb 12, 2024 · 0 comments
Open

Comments

@nyngwang
Copy link

nyngwang commented Feb 12, 2024

As title.

So I have a project with "type": "module'' set. Now JSDoc is complaining that:

> babel jsdoc.js --config-file ./babel2.config.js -o temp.cjs &&
 jsdoc -c temp.cjs

Cannot parse the config file temp.cjs: SyntaxError: Unexpected n
on-whitespace character after JSON at position 12
Exiting JSDoc because an error occurred. See the previous log me
ssages for details.
There are no input files to process.

if I insist on using .js I got another error:

Cannot parse the config file temp.js: Error [ERR_REQUIRE_ESM]: r
equire() of ES Module /path/to/temp.js fr
om /path/to/node_modules/jsdoc/cli.js not
 supported.
temp.js is treated as an ES module file as it is a .js file whos
e nearest parent package.json contains "type": "module" which de
clares all .js files in that package scope as ES modules.
Instead either rename temp.js to end in .cjs, change the requiri
ng code to use dynamic import() which is available in all Common
JS modules, or change "type": "module" to "type": "commonjs" in 
/path/to/package.json to treat all .js fi
les as CommonJS (using .mjs for all ES modules instead).

Exiting JSDoc because an error occurred. See the previous log me
ssages for details.
There are no input files to process.

related

#2035
#2006

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant