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

nyc.config.js in "type": "module" project #1518

Open
robrich opened this issue May 11, 2023 · 0 comments
Open

nyc.config.js in "type": "module" project #1518

robrich opened this issue May 11, 2023 · 0 comments

Comments

@robrich
Copy link

robrich commented May 11, 2023

Repro steps:

  1. set package.json: "type": "module"
  2. create dynamic config: nyc.config.js file with any options
  3. run any nyc command: npx nyc npm run test

Expected behavior:

It loads the nyc.config settings then runs the test

Actual behavior:

ReferenceError: module is not defined in ES module scope
This file is being treated as an ES module because it has a '.js' file extension and 'C:\path\to\my\package.json' contains "type": "module". To treat it as a CommonJS script, rename it to use the '.cjs' file extension.
    at file:///C:/path/to/my/nyc.config.js:8:1
    at ModuleJob.run (node:internal/modules/esm/module_job:192:25)

or

Error: Failed to load nyc.config.js: require() of ES Module C:\path\to\my\nyc.config.js from C:\path\to\my\node_modules\@cypress\code-coverage\task-utils.js not supported.

Attempted work-arounds:

  • Rename config to nyc.config.cjs: doesn't pick up config
  • Rename config to nyc.config.ts: doesn't pick up config
  • Change file content to ES6 module syntax: different error, but still errors
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