初始化时 Eslint 错误!针对爱彼迎标准运行“eslint --init”时,JSON 中位置 139 处出现意外标记 {

Tre*_*ell 3 javascript json ecma node.js eslint

我在运行 eslint init 时收到此错误,它似乎不是由我的任何文件触发的,而是由它自己的代码触发的。我在另一个网站上看到有人有同样的错误消息。我尝试卸载并重新安装并尝试旧版本但无济于事。

oem@Trevor:~/signal-labs-nodejs-coding-challenege$ eslint --init
? How would you like to use ESLint? To check syntax, find problems, and enforce code style
? What type of modules does your project use? JavaScript modules (import/export)
? Which framework does your project use? None of these
? Does your project use TypeScript? No
? Where does your code run? Browser, Node
? How would you like to define a style for your project? Use a popular style guide
? Which style guide do you want to follow? Airbnb: https://github.com/airbnb/javascript
? What format do you want your config file to be in? JavaScript
Checking peerDependencies of eslint-config-airbnb-base@latest
Unexpected token { in JSON at position 139
SyntaxError: Unexpected token { in JSON at position 139
    at JSON.parse (<anonymous>)
    at Object.fetchPeerDependencies (/usr/local/lib/node_modules/eslint/lib/init/npm-utils.js:83:17)
    at getPeerDependencies (/usr/local/lib/node_modules/eslint/lib/init/config-initializer.js:81:27)
    at hasESLintVersionConflict (/usr/local/lib/node_modules/eslint/lib/init/config-initializer.js:388:30)
    at Object.when (/usr/local/lib/node_modules/eslint/lib/init/config-initializer.js:568:83)
    at /usr/local/lib/node_modules/eslint/node_modules/run-async/index.js:25:25
    at new Promise (<anonymous>)
    at /usr/local/lib/node_modules/eslint/node_modules/run-async/index.js:24:19
    at /usr/local/lib/node_modules/eslint/node_modules/inquirer/lib/ui/prompt.js:114:32
    at Observable._subscribe (/usr/local/lib/node_modules/eslint/node_modules/rxjs/internal/observable/defer.js:10:21)
Run Code Online (Sandbox Code Playgroud)

for*_*orf 5

就我而言,这是由于我的项目中存在旧版本的节点造成的。更新节点版本为我解决了这个问题。