You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I tried to add XO to a Next.js project and I get the following error on npx xo:
node:internal/process/esm_loader:94
internalBinding('errors').triggerUncaughtException(
^
Error [ERR_MODULE_NOT_FOUND]: Cannot find package '/Users/patrikcsak/Code/next-xo/node_modules/xo/node_modules/eslint/' imported from /Users/patrikcsak/Code/next-xo/node_modules/xo/index.js
Did you mean to import eslint/lib/api.js?
at new NodeError (node:internal/errors:371:5)
at legacyMainResolve (node:internal/modules/esm/resolve:335:9)
at packageResolve (node:internal/modules/esm/resolve:877:14)
at moduleResolve (node:internal/modules/esm/resolve:929:18)
at defaultResolve (node:internal/modules/esm/resolve:1044:11)
at ESMLoader.resolve (node:internal/modules/esm/loader:422:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:222:40)
at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
at link (node:internal/modules/esm/module_job:75:36) {
code: 'ERR_MODULE_NOT_FOUND'
}
Did you mean eslint and eslint-config-next? That gets XO working, but then we lose Next.js's ESLint rules. In the reproduction above, XO wasn't yet configured to use Next.js's ESLint rules, but my goal is to use XO with Next.js's ESLint rules.
Thanks for the advice about deleting the lock file and node_modules/. Haven't had to do that in a while!
I got XO working with Next.js's ESLint rules using the following steps:
For anyone still struggling with this, I created eslint-config-xo-next which works as a thin compatibility that makes Next.js’s and XO’s configs work together: https://github.com/patrik-csak/eslint-config-xo-next
Activity
sindresorhus commentedon Nov 11, 2021
This seems like a npm issue.
Removing
eslintandeslint-config-xowhich are not needed, and then remove lock file and reinstall node_modules fixes the issue for me.patrik-csak commentedon Nov 11, 2021
Did you mean
eslintandeslint-config-next? That gets XO working, but then we lose Next.js's ESLint rules. In the reproduction above, XO wasn't yet configured to use Next.js's ESLint rules, but my goal is to use XO with Next.js's ESLint rules.Thanks for the advice about deleting the lock file and
node_modules/. Haven't had to do that in a while!I got XO working with Next.js's ESLint rules using the following steps:
eslintandeslint-config-nextnode_modules/, and reinstall dependencies:create-next-app:next lintwithxoinpackage.json:"scripts": { - "lint": "next lint" + "lint": "xo" }See working example at https://github.com/ptrkcsk/next-xo/tree/next-plugin
fregante commentedon Aug 6, 2022
That looks about right. The steps are the same as switching any project from ESLint to XO
patrik-csak commentedon Sep 22, 2026
For anyone still struggling with this, I created
eslint-config-xo-nextwhich works as a thin compatibility that makes Next.js’s and XO’s configs work together: https://github.com/patrik-csak/eslint-config-xo-next