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

Template project ESLint fails to run #5310

Closed
zizhengtai opened this issue Jun 29, 2022 · 1 comment
Closed

Template project ESLint fails to run #5310

zizhengtai opened this issue Jun 29, 2022 · 1 comment

Comments

@zizhengtai
Copy link

zizhengtai commented Jun 29, 2022

Describe the bug

npm run lint or npx eslint src fails to run on a freshly created SvelteKit project, complaining that Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/zizheng/Projects/my-app/.eslintrc.js from /Users/zizheng/Projects/my-app/node_modules/@eslint/eslintrc/dist/eslintrc.cjs not supported. ... (see logs section for details).

Reproduction

The following steps can be reproduced

  • both on macOS 12.4 and Windows 11
  • both with the demo project and the skeleton project
  • both with and without TypeScript
$ npm create svelte my-app
...
✔ Which Svelte app template? › Skeleton project
✔ Add type checking with TypeScript? › No
✔ Add ESLint for code linting? … Yes
✔ Add Prettier for code formatting? … No
✔ Add Playwright for browser testing? … No
...
$ cd my-app
$ npm install
$ npm run lint

Logs

$ npm --version
8.13.1

$ npm create svelte my-app

create-svelte version 2.0.0-next.143

Welcome to SvelteKit!

This is beta software; expect bugs and missing features.

Problems? Open an issue on https://github.com/sveltejs/kit/issues if none exists already.

✔ Which Svelte app template? › Skeleton project
✔ Add type checking with TypeScript? › No
✔ Add ESLint for code linting? … Yes
✔ Add Prettier for code formatting? … No
✔ Add Playwright for browser testing? … No

Your project is ready!
✔ ESLint
  https://github.com/sveltejs/eslint-plugin-svelte3

Install community-maintained integrations:
  https://github.com/svelte-add/svelte-adders

Next steps:
  1: cd my-app
  2: npm install (or pnpm install, etc)
  3: git init && git add -A && git commit -m "Initial commit" (optional)
  4: npm run dev -- --open

To close the dev server, hit Ctrl-C

Stuck? Visit us at https://svelte.dev/chat

$ cd my-app

$ npm install

> my-app@0.0.1 prepare
> svelte-kit sync


added 183 packages, and audited 184 packages in 13s

21 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities

$ npm run lint

> my-app@0.0.1 lint
> eslint .


Oops! Something went wrong! :(

ESLint: 8.18.0

Error [ERR_REQUIRE_ESM]: require() of ES Module /Users/zizheng/Projects/my-app/.eslintrc.js from /Users/zizheng/Projects/my-app/node_modules/@eslint/eslintrc/dist/eslintrc.cjs not supported.
Instead change the require of .eslintrc.js in /Users/zizheng/Projects/my-app/node_modules/@eslint/eslintrc/dist/eslintrc.cjs to a dynamic import() which is available in all CommonJS modules.
    at module.exports [as default] (/Users/zizheng/Projects/my-app/node_modules/import-fresh/index.js:32:59)
    at loadJSConfigFile (/Users/zizheng/Projects/my-app/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2559:47)
    at loadConfigFile (/Users/zizheng/Projects/my-app/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2643:20)
    at ConfigArrayFactory.loadInDirectory (/Users/zizheng/Projects/my-app/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:2840:34)
    at CascadingConfigArrayFactory._loadConfigInAncestors (/Users/zizheng/Projects/my-app/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3833:46)
    at CascadingConfigArrayFactory.getConfigArrayForFile (/Users/zizheng/Projects/my-app/node_modules/@eslint/eslintrc/dist/eslintrc.cjs:3754:18)
    at FileEnumerator._iterateFilesRecursive (/Users/zizheng/Projects/my-app/node_modules/eslint/lib/cli-engine/file-enumerator.js:446:49)
    at _iterateFilesRecursive.next (<anonymous>)
    at FileEnumerator.iterateFiles (/Users/zizheng/Projects/my-app/node_modules/eslint/lib/cli-engine/file-enumerator.js:297:49)
    at iterateFiles.next (<anonymous>)
    at CLIEngine.executeOnFiles (/Users/zizheng/Projects/my-app/node_modules/eslint/lib/cli-engine/cli-engine.js:786:48)
    at ESLint.lintFiles (/Users/zizheng/Projects/my-app/node_modules/eslint/lib/eslint/eslint.js:550:23)
    at Object.execute (/Users/zizheng/Projects/my-app/node_modules/eslint/lib/cli.js:301:36)
    at main (/Users/zizheng/Projects/my-app/node_modules/eslint/bin/eslint.js:138:52)
    at Object.<anonymous> (/Users/zizheng/Projects/my-app/node_modules/eslint/bin/eslint.js:142:2)

System Info

  System:
    OS: macOS 12.4
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 9.94 GB / 32.00 GB
    Shell: 3.5.0 - /usr/local/bin/fish
  Binaries:
    Node: 18.4.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 8.13.1 - /usr/local/bin/npm
  Browsers:
    Firefox: 102.0
    Safari: 15.5
  npmPackages:
    @sveltejs/adapter-auto: next => 1.0.0-next.52
    @sveltejs/kit: next => 1.0.0-next.355
    svelte: ^3.44.0 => 3.48.0

Severity

annoyance

Additional Information

No response

@gtm-nayan
Copy link
Contributor

Should be fixed by #5293, just waiting on the next release of create-svelte

For now you can rename your eslintrc file to a .cjs extension and change the export default inside to module.exports =

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

2 participants