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

ESLint cannot find next/babel when using pnpm #1600

Closed
ChristianIvicevic opened this issue Jul 30, 2022 · 14 comments · Fixed by #1884
Closed

ESLint cannot find next/babel when using pnpm #1600

ChristianIvicevic opened this issue Jul 30, 2022 · 14 comments · Fixed by #1884
Labels
area: examples Improvements or additions to examples

Comments

@ChristianIvicevic
Copy link

What version of Turborepo are you using?

1.4.0

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

pnpm

What operating system are you using?

Mac

Describe the Bug

After checking out the repository and opening the with-pnpm example and running pnpm install I noticed that ESLint is having issues in the editor. It claims that there is no module next/babel and this error is displayed both in WebStorm and VSCode. My gut feeling is that next/babel is usually referenced as a transitive peer dependency which doesn't work well with the strict nature of pnpm.

image

The error appears only when opening the root .eslintrc.js and the index.js in the eslint-config-custom package. Linting generally works and running pnpm lint works as well, it is just really annoying seeing errors when editing either of the files. Opening the basic example or a repository scaffolded with create-turbo and using npm instead of pnpm does not have this particular issue.

Expected Behavior

No ESLint errors in any configuration file.

To Reproduce

Open the with-pnpm example in WebStorm or VSCode with enabled ESLint plugins and install dependencies using pnpm. I could reproduce this with v6.32.25 and v7.7.0 of pnpm both installed with corepack.

@shametim
Copy link

shametim commented Jul 30, 2022

you can try configuring your eslint plugin to detect your workspaces under vscode settings.

eslint.workingDirectories: [{ "pattern": "apps/*" }]

i'm still trying to find out why this happens with pnpm in the first place or why this resolves it.

@ChristianIvicevic
Copy link
Author

Even though this proposal can also be applied to WebStorm there is an inherent incompatiblity with pnpm that's not fixed by this. For the time being I applied the pattern I used in the nx-version of my repo with declaring ignorePatterns: ['**/*'] in the eslint-config-custom and then reverting this in the .eslintrc.js within my apps and packages as follows:

module.exports = {
  root: true,
  ignorePatterns: ['!**/*'],
  extends: ['custom'],
};

@weyert
Copy link
Contributor

weyert commented Aug 1, 2022

Maybe this patch from Rush, could also improve things:
https://www.npmjs.com/package/@rushstack/eslint-patch

@ChristianIvicevic
Copy link
Author

Sadly I won't be able to test the suggested patch since I completely gave up on pnpm again.

Every few months when I try it out there is still issues with packages not adhering to decent standards and thus being incompatible with pnpm. This time around it was prisma... but that is offtopic and another story.

@brizzbuzz
Copy link

Screen Shot 2022-08-03 at 8 50 31 PM

I get a similar error though I am using yarn :(

@mehulkar
Copy link
Contributor

mehulkar commented Sep 8, 2022

Try using degit to clone down the directory instead of cloning this whole repo. I've added readme instructions in #1884 and I was able to run npm run lint successfully that way and also don't see any issues in VSCode (which is admittedly not WebStorm, but since we've had multiple issues reported about this, I think it is probably a similar config issue)

@kodiakhq kodiakhq bot closed this as completed in #1884 Sep 8, 2022
@kodiakhq kodiakhq bot closed this as completed in b1ae207 Sep 8, 2022
@Adam-Collier
Copy link

Adam-Collier commented Oct 14, 2022

I still look to be having this issue using VS Code 😬

@mehulkar mehulkar reopened this Oct 14, 2022
@mehulkar
Copy link
Contributor

This may be the same root cause as #1911 in that next dependency isn't available, rather than an issue related to pnpm 🤔 . Not sure when I'll have time to dig into it, but our examples/ setup needs a bit of love.

@mehulkar mehulkar added the area: examples Improvements or additions to examples label Oct 14, 2022
@bryanbarrios
Copy link

bryanbarrios commented Dec 29, 2022

Any update on this issue? When I generate the default project using pnpm create turbo@latest (with Next 13), I keep getting the error "cannot find module next/babel". I tried adding the working directories, but this didn't resolve the error.

@Hamziss
Copy link

Hamziss commented Jan 19, 2023

found out a hacky way to fix this
create a settings file .vscode/settings.json or add it to your global settings.json

  "eslint.workingDirectories": [
    { "pattern": "apps/*/" },
    { "pattern": "packages/*/" }
  ]

@steida
Copy link

steida commented Jan 20, 2023

@Hamziss Didn't work for me 😞

@barthicus
Copy link

@Hamziss Installing next in root package.json solves this but it's hacky solution to me and I don't like it. I used it though.

@tknickman
Copy link
Member

@ImBIOS has put up a nice approach to address this here: #3489

@tknickman
Copy link
Member

Merged, going to close for now, but please reopen if this issue comes up again!

steida added a commit to evoluhq/evolu that referenced this issue Jan 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: examples Improvements or additions to examples
Projects
None yet
Development

Successfully merging a pull request may close this issue.