eslint-plugin-unicorn: Error: Failed to load plugin 'eslint-plugin-unicorn' declared in '--config#overrides[2]': Cannot find module 'node:path'
Upgrading eslint-plugin-unicorn
from 42.0.0
to 43.0.0
results in the following error:
@:~/> yarn lint
\ Processing: electron/src/preload.ts
Oops! Something went wrong! :(
ESLint: 8.19.0
Error: Failed to load plugin 'eslint-plugin-unicorn' declared in '--config#overrides[2]': Cannot find module 'node:path'
Require stack:
- /node_modules/eslint-plugin-unicorn/rules/utils/rule.js
- /node_modules/eslint-plugin-unicorn/index.js
- /node_modules/@eslint/eslintrc/dist/eslintrc.cjs
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
at Object.<anonymous> (/node_modules/eslint-plugin-unicorn/rules/utils/rule.js:2:14)
at Module._compile (/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
I reverted the version back and it worked
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 5
- Comments: 34
Closing since we are not going to do anything, please use a Node version that supports
require("node:path")
Using Node 16.4.0 and seeing the error:
I confirmed
node:path
is importable in this version by runningnode -e 'console.log(typeof require("node:path"))'
which yieldsobject
. What could be the problem?Edit: Also affects Node 16.17.0, BUT I’ve noticed this issue is only present on Linux - on Windows it works fine. @fisker I think something may indeed need to be done to resolve this. Downgrading to
42.x
yields a working ESLint config on all OS.Node.js document that it’s supported https://nodejs.org/dist/latest-v16.x/docs/api/modules.html#:~:text=Added node: import support to, if you are still facing this issue, please report to Node.js
This is happening because the library was bumped in v43 to require >= Node 14.18, where the
node:
protocol import syntax was introduced. If this is failing for you (as it is for us) it’s because you’re on an earlier version of Node.@Slapbox , I am on Mac OS
I don’t really understand the issue here. Is it that hard to setup a reproduction? If many of you already have problems, can you just delete your private stuff and put your code somewhere, so I can debug. I didn’t even ask it has to be minimum.
I am seeing this error when trying to add Typescript to Nuxt, in their documentation you install
@nuxtjs/eslint-config-typescript
whicheslint-plugin-unicorn
is a dependancy of https://typescript.nuxtjs.org/guide/lint/, using node v16.17.1Seeing this error on a fresh oclif generated app after running
npm update
and manually forcing eslint to upgrade to 8.x. I’m on MacOS running node 16.18.0.I haven’t dug enough to see if this is just a compatbility issue with the rules in
eslint-config-oclif
with the latest version of eslint or what. Checking that now.In your package.json, simply change your versioning to accept upcoming minor & patch updates, that is by having:
"version": "2.0.0"
instead of"version": "2"
I am actually on node 16 @fisker @erunion . not sure why this issue was closed and noone wanted to check with me which node i am on 😃
rm -rf node_modules && rm package-lock.json && npm i
solved it for meIf the Node.js version is the problem, why it’s fine to stay on old Node.js version, but not fine to stay on old unicorn version?
But still, this issue should be open because it’s a real issue.
I’m seeing the same issue, but with a twist. It works on my local dev (Mac) machine, but fails on our CI (Windows) machine.
As can be seen below, it’s running Node 16.
I’m downgrading to version 42 to solve it for now, but wanted to leave this here to help with the root cause investigation.
Just my two cents - it seems like all this suffering is not worth using node:* style require statements. We’re still on an older version because of this issue. It really should not be closed as it’s apparent that people whose machines meet the stated package requirements are having trouble with it on multiple machines. @fisker.
Spent a bit of time working around this, but got typescript enabled within our nuxt project without
@nuxtjs/eslint-config-typescript
..eslintrc.js has ->
Since we are migrating from JS to TS we still need to allow both so have this within out tsconfig.json file ->
Now TS files and vue files with
script lang="ts"
lint correctly as well as normal vue files.With Node 15.x this problem also occurs 😢