turborepo: [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 3 years ago
- Reactions: 9
- Comments: 19 (4 by maintainers)
I resolved the problem by upgrading “eslint-config-turbo” in package.json in “eslint-config” package to the newest version.
had the same problem.
Based on https://github.com/microsoft/vscode-eslint/issues/1373, I have added the following to my
.npmrc:After running
pnpm iand 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 issueI also had to update
eslint-plugin-turbo. I used the codegen, but we are using a monorepo and the codegen upgrade didn’t catch theeslint-plugin-turboinside ourpackages/eslint-config.@stevemu thank you, this happened to me after upgrading
turbopackage without theeslint-config-turbo.@stevemu thanks a bunch , it worked for me
For me it also appears when I add turbo.json files to my workspace directories, with something like this:
Adding this to some of my packages, also seems to make linting fail on other package that do not have a turbo file.
I solved it by declaring the global dependencies at the root with
**/prefixI had the same issue, there was an invalid turbo.json file in one of my packages, fixing that fixed the load plugin error