曾几何时,我想写一个应用程序。我了解了常见的做法,它让我有了越来越多的发现。突然,我发现了about lint
,这意味着美丽的代码模式。在我的应用程序中,我发现了这个命令,它的名字backend-app
、味道javascript
和香料都包含在内。我以为我会从此过上幸福的生活,但坏人的出现却把我压得落泪。node-js
eslint src/ --fix
error 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
已安装的软件包存在一些冲突。
- 运行命令
sudo apt remove '*eslint*' --dry-run
; - 运行命令
sudo apt remove '*eslint*'
; - 转到项目文件夹;
- 删除文件夹
node_modules
和文件package-lock.json
; - 运行命令
npm i
- 运行命令
eslint --fix