初始化时出现 eslint 错误!针对Airbnb标准运行 'eslint --init' 时,JSON 中位置 139 处的意外标记 {



我在运行 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)

就我而言,这是由于我的项目中有一个古老的节点版本引起的。更新节点版本为我修复了它。

同样的事情也发生在我身上。 问题出在没有必要权限的 .npm 文件夹中。 我运行了命令:

sudo chmod -R 777 /home/<user>/.npm

一切都恢复了正常工作

有一个关于这个问题的问题,这是他们的解决方案:

sudo npm cache clean --force

之后安装顺利进行。

相关内容

  • 没有找到相关文章

最新更新