Linux 命令“eslint”的 eslint 损坏

Linux 命令“eslint”的 eslint 损坏

曾几何时,我想写一个应用程序。我了解了常见的做法,它让我有了越来越多的发现。突然,我发现了about lint,这意味着美丽的代码模式。在我的应用程序中,我发现了这个命令,它的名字backend-app、味道javascript和香料都包含在内。我以为我会从此过上幸福的生活,但坏人的出现却把我压得落泪。node-jseslint src/ --fixerror log

node:internal/modules/cjs/loader:998
  throw err;
  ^

Error: Cannot find module 'optionator'
Require stack:
- /usr/share/nodejs/eslint/lib/options.js
- /usr/share/nodejs/eslint/lib/cli.js
- /usr/share/nodejs/eslint/bin/eslint.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
    at Module._load (node:internal/modules/cjs/loader:841:27)
    at Module.require (node:internal/modules/cjs/loader:1061:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (/usr/share/nodejs/eslint/lib/options.js:12:20)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Module.require (node:internal/modules/cjs/loader:1061:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/usr/share/nodejs/eslint/lib/options.js',
    '/usr/share/nodejs/eslint/lib/cli.js',
    '/usr/share/nodejs/eslint/bin/eslint.js'
  ]
}

Node.js v18.12.1

答案1

问题是与apt已安装的软件包存在一些冲突。

  1. 运行命令sudo apt remove '*eslint*' --dry-run
  2. 运行命令sudo apt remove '*eslint*'
  3. 转到项目文件夹;
  4. 删除文件夹node_modules和文件package-lock.json
  5. 运行命令npm i
  6. 运行命令eslint --fix

相关内容