turbo: [turborepo] Failed to load plugin 'turbo' declared in 'apps/backend/.eslintrc.js » eslint-config-custom » eslint-config-turbo': Cannot find module 'eslint-plugin-turbo'

What version of Turborepo are you using?

1.109

What package manager are you using / does the bug impact?

pnpm

What operating system are you using?

Mac

Describe the Bug

This works fine while trying to run pnpm run lint but fails in VS Code only Creating a new monorepo with setting up nestjs popups the error in VSCode below:
Error: Failed to load plugin ‘turbo’ declared in ‘apps/backend/.eslintrc.js » eslint-config-custom » eslint-config-turbo’:
Cannot find module ‘eslint-plugin-turbo’. Require stack:

  • /Users/divyanshgupta/Projects/monorepo/apps/backend/placeholder.js Referenced from: /Users/divyanshgupta/Projects/monorepo/node_modules/.pnpm/eslint-config-turbo@1.9.3_eslint@8.45.0/node_modules/eslint-config-turbo/index.js at Module._resolveFilename (node:internal/modules/cjs/loader:1010:15) at Function.resolve (node:internal/modules/cjs/helpers:108:19)

packages/eslint-config-custom/index.js module.exports = { extends: ["turbo"], "rules": { // Automatically flag env vars missing from turbo.json "turbo/no-undeclared-env-vars": "off" } };

packages/eslint-config-custom/package.json { "name": "eslint-config-custom", "version": "0.0.0", "main": "index.js", "license": "MIT", "dependencies": { "eslint-config-prettier": "^8.3.0", "eslint-config-turbo": "^1.9.3" }, "publishConfig": { "access": "public" } }

./.eslintrc.js module.exports = { root: true, // This tells ESLint to load the config from the package eslint-config-custom extends: ["custom"], settings: { next: { rootDir: ["apps/*/"], }, }, };

/apps/backend/.eslintrc.js module.exports = { parser: '@typescript-eslint/parser', parserOptions: { project: 'tsconfig.json', tsconfigRootDir: __dirname, sourceType: 'module', }, plugins: ['@typescript-eslint/eslint-plugin'], root: true, extends: [ 'custom', 'plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended', ], env: { node: true, jest: true, }, ignorePatterns: ['.eslintrc.js'], rules: { '@typescript-eslint/interface-name-prefix': 'off', '@typescript-eslint/explicit-function-return-type': 'off', '@typescript-eslint/explicit-module-boundary-types': 'off', '@typescript-eslint/no-explicit-any': 'off', '@typescript-eslint/ban-ts-comment': 'off', }, };

Expected Behavior

eslint should properly work in vscode

To Reproduce

setup a new turborepo with nestjs with above config

Reproduction Repo

No response

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Reactions: 6
  • Comments: 15 (3 by maintainers)

Most upvoted comments

had the same problem.

Based on https://github.com/microsoft/vscode-eslint/issues/1373, I have added the following to my .npmrc:

public-hoist-pattern[]=*eslint-plugin-*
public-hoist-pattern[]=@typescript-eslint/eslint-plugin

After running pnpm i and restarting the VSC eslint server, it seems the linting is working again.

We encountered this issue and removing public-hoist-pattern[]=*prisma* from the .npmrc has solved the issue