question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Failed to load parser './parser.js' declared in .eslintrc.json

See original GitHub issue

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

next info output

    Operating System:
      Platform: darwin
      Arch: x64
      Version: Darwin Kernel Version 21.6.0: Sat Jun 18 17:07:25 PDT 2022; root:xnu-8020.140.41~1/RELEASE_X86_64
    Binaries:
      Node: 16.16.0
      npm: 8.11.0
      Yarn: 3.2.2
      pnpm: N/A
    Relevant packages:
      next: 12.2.3-canary.17
      eslint-config-next: N/A
      react: 18.2.0
      react-dom: 18.2.0

package.json

{
  "name": "web",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint",
    "info": "next info"
  },
  "dependencies": {
    "next": "canary",
    "react": "18.2.0",
    "react-dom": "18.2.0"
  },
  "devDependencies": {
    "eslint": "8.20.0",
    "eslint-config-next": "12.2.3"
  }
}

What browser are you using? (if relevant)

NA

How are you deploying your application? (if relevant)

NA

Describe the Bug

next dev is working fine, but next lint is failing with the following error.

info  - SWC minify release candidate enabled. https://nextjs.link/swcmin
Failed to load parser './parser.js' declared in '.eslintrc.json » eslint-config-next/core-web-vitals » /Users/sumit.goel/Development/monorepo/.yarn/__virtual__/eslint-config-next-virtual-c1b113f562/0/cache/eslint-config-next-npm-12.2.3-8aa11ec9cd-bba70ac318.zip/node_modules/eslint-config-next/index.js': eslint-config-next tried to access next, but it isn't declared in its dependencies; this makes the require call ambiguous and unsound.

Required package: next (via "next/dist/compiled/babel/eslint-parser")
Required by: eslint-config-next@virtual:569035de073023aa8b0b5018956311b227b0a904329a09033178811fc3e35e666a9055672cf1571918d7dc6006c37bb02ee20b7a6a08428927cea962afec4a25#npm:12.2.3 (via /Users/sumit.goel/Development/monorepo/.yarn/__virtual__/eslint-config-next-virtual-c1b113f562/0/cache/eslint-config-next-npm-12.2.3-8aa11ec9cd-bba70ac318.zip/node_modules/eslint-config-next/)

Require stack:
- /Users/sumit.goel/Development/monorepo/.yarn/__virtual__/eslint-config-next-virtual-c1b113f562/0/cache/eslint-config-next-npm-12.2.3-8aa11ec9cd-bba70ac318.zip/node_modules/eslint-config-next/parser.js
- /Users/sumit.goel/Development/monorepo/.yarn/cache/@eslint-eslintrc-npm-1.3.0-1f3c51be25-a1e734ad31.zip/node_modules/@eslint/eslintrc/dist/eslintrc.cjs

Expected Behavior

The next lint command is successful with no errors.

Link to reproduction

Please check the steps below to reproduce.

To Reproduce

$ mkdir monorepo && cd "$_"
$ yarn init -2 -p -w
$ yarn create next-app packages/web
$ yarn workspace web add next@canary
$ yarn workspace web run lint

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:5
  • Comments:12 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
reck1esscommented, Jul 26, 2022
// .yarnrc.yaml at project root 

packageExtensions:
  eslint-config-next@*:
    dependencies:
      next: "*"

yarnPath: .yarn/releases/yarn-3.2.2.cjs

4reactions
sumitgoelpwcommented, Jul 29, 2022

Thank you so much @reck1ess It works.

I had to add react and react-dom as well to get rid of the warnings.

➤ YN0000: ┌ Resolution step
➤ YN0002: │ eslint-config-next@npm:12.2.3 [56903] doesn't provide react (p8e5fd), requested by next
➤ YN0002: │ eslint-config-next@npm:12.2.3 [56903] doesn't provide react-dom (p0ccb9), requested by next
➤ YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code
➤ YN0000: └ Completed in 2s 101ms
➤ YN0000: ┌ Fetch step
➤ YN0000: └ Completed
➤ YN0000: ┌ Link step
➤ YN0000: │ ESM support for PnP uses the experimental loader API and is therefore experimental
➤ YN0000: └ Completed
➤ YN0000: Done with warnings in 2s 267ms
packageExtensions:
  eslint-config-next@*:
    dependencies:
      next: "*"
      react: "*"
      react-dom: "*"
Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Failed to load parser '@typescript-eslint/parser' declared ...
I am creating an add-to-cart app in vuejs. I am using the typescript language in vuejs but the babel-eslint parser keeps giving me...
Read more >
Error: Failed to load parser 'babel-eslint' declared in '.eslintrc ...
To fix this issue just reuse babel-eslint dependency from react-scripts , that already installed. Update your config:
Read more >
Failed to load parser '@typescript-eslint/parser' declared in ...
Failed to load parser '@typescript-eslint/parser' declared in .eslintrc.json: Cannot find module json-schema.
Read more >
Failed to load parser '@typescript-eslint/parser ... - Reddit
I'm getting this error when running :ALEInfo. Googling the error, all of the advice says to make sure eslint is updated with npm...
Read more >
failed to load parser '@angular-eslint/template-parser' - You.com
@jeremybarbet . Are you seeing: Error: Failed to load parser '@babel/eslint-parser' declared in '.eslintrc.js': Cannot find module ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found