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

Update getting-started.md #4000

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Yeti-or
Copy link

@Yeti-or Yeti-or commented Mar 31, 2024

Use esm module in getting started section

Description

failure just after copypasting from setup section

npx commitlint --last --verbose

export default { extends: ['@commitlint/config-conventional'] };
^^^^^^

SyntaxError: Unexpected token 'export'

just use .mjs format to let node.js use esm

Motivation and Context

Usage examples

// commitlint.config.js
module.exports = {};
echo "your commit message here" | commitlint # fails/passes

How Has This Been Tested?

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

@escapedcat
Copy link
Member

escapedcat commented Apr 1, 2024

Which node version are you using?
Can't reproduce this with v18/20

@escapedcat
Copy link
Member

Closing because of missing feedback. Please re-open if wanted.

@escapedcat escapedcat closed this Apr 8, 2024
@KingMob
Copy link

KingMob commented Apr 23, 2024

I'm seeing this exact issue with node v20.11.1, after following the installation instructions. I think it's worth reopening.

❯ cat commitlint.config.js
export default { extends: ['@commitlint/config-conventional'] };
❯ npx commitlint --print-config
(node:9825) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/Users/matthew/Code/probcomp/GenSQL.query/commitlint.config.js:1
export default { extends: ['@commitlint/config-conventional'] };
^^^^^^

SyntaxError: Unexpected token 'export'
    at internalCompileFunction (node:internal/vm:77:18)
    at wrapSafe (node:internal/modules/cjs/loader:1288:20)
    at Module._compile (node:internal/modules/cjs/loader:1340:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at module.exports (/Users/matthew/Code/probcomp/GenSQL.query/node_modules/import-fresh/index.js:32:59)
    at loadJsSync (/Users/matthew/Code/probcomp/GenSQL.query/node_modules/cosmiconfig/dist/loaders.js:17:12)
    at loadJs (/Users/matthew/Code/probcomp/GenSQL.query/node_modules/cosmiconfig/dist/loaders.js:27:43) {
  filepath: '/Users/matthew/Code/probcomp/GenSQL.query/commitlint.config.js'
}

Node.js v20.11.1

@KingMob
Copy link

KingMob commented Apr 23, 2024

I can confirm that changing the suffix from .js to .mjs fixes it for now.

@escapedcat
Copy link
Member

Thanks for your feedback. Can reproduce this now as well.
Wondering why this worked before.
There might be an underlying issue that should be fixed instead of the docs.

@escapedcat escapedcat reopened this Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants