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: Unable to resolve path to module '@vercel/analytics/react' (import/no-unresolved) #18

Closed
elijahcarrel opened this issue Nov 17, 2022 · 7 comments

Comments

@elijahcarrel
Copy link

Steps to reproduce:

Expected behavior:

  • Deployment is successful

Actual behavior:

  • Deployment fails:
2022-11-17T04:00:34.842Z  Failed to compile.
2022-11-17T04:00:34.842Z
2022-11-17T04:00:34.842Z  ./pages/_app.tsx
2022-11-17T04:00:34.843Z  10:27  Error: Unable to resolve path to module '@vercel/analytics/react'.  import/no-unresolved

Workaround:

  • Add // eslint-disable-next-line import/no-unresolved before import { Analytics } from "@vercel/analytics/react";.

Version:
0.1.5

This is also as described in https://stackoverflow.com/a/74453475/2736037.

@tobiaslins
Copy link
Collaborator

Hey!
Thanks for reporting. We'll take a closer look into this.
I'll keep you posted!

@tobiaslins
Copy link
Collaborator

tobiaslins commented Nov 21, 2022

Hey!
I just had a deeper look into this. It seems like you don't have the plugin eslint-import-resolver-typescript which is required that Eslint knows how to resolve this module.

I saw that you have installed eslint-config-next but not using it (which uses this resolver plugin). You did import "plugin:@next/next/recommended" instead.
If you change the eslint config to include following, it should work (be sure to use the latest version of eslint-config-next. (The Next.js config includes the eslint plugin you'll need)

 extends: [
    "airbnb-typescript-prettier",
    "next",
  ],

Else you can just install the required plugin:
https://github.com/import-js/eslint-import-resolver-typescript

Let me know if it works! :)

@Hearmstrong
Copy link

@tobiaslins Would this be the same process in a non-typescript project?

@timolins
Copy link
Member

@Hearmstrong It might not be required. There is a JavaScript version as well: https://www.npmjs.com/package/eslint-plugin-import

Note that I haven't tested this out.

@tobiaslins
Copy link
Collaborator

Will close this for now. Let us know if you still have problems!

@gsheppard
Copy link

I have the next configuration for eslint, but I am still seeing this issue.

extends: [
  'next/core-web-vitals',
  'plugin:@typescript-eslint/recommended',
  'airbnb-base',
  'airbnb-typescript',
  'next',
  'prettier',
],

Admittedly a lot of this config is old and haven't audited it in a while. Nor sure if there are any conflicts happening.

@elijahcarrel
Copy link
Author

Thank you so much @tobiaslins! That was exactly my problem and your solution worked. I'm surprised I managed to get this far in my app without actually using eslint-import-resolver-typescript until now 😅.

elijahcarrel added a commit to elijahcarrel/inbox-comics that referenced this issue Mar 11, 2023
Uses the solution described in vercel/analytics#18 (comment) to fix eslint config, which removes the need for my eslint-ignore directive.

Also fixes some minor lint issues that leaked into codebase.
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

5 participants