简体   繁体   English

初始化时出现 Eslint 错误! 意外令牌 { 在 JSON 中的位置 139 运行 'eslint --init' 以符合 airbnb 标准

[英]Eslint error upon initialization! Unexpected token { in JSON at position 139 when running 'eslint --init' for airbnb standards

I'm getting this error when running eslint init, It doesnt appear to be triggered by any of my files, rather by its own code.运行 eslint init 时出现此错误,它似乎不是由我的任何文件触发,而是由它自己的代码触发。 I've seen someone on another site with the same error message.我在另一个网站上看到有人有同样的错误信息。 I've tried to uninstall and reinstall and tried an older version to no avail.我尝试卸载并重新安装并尝试使用旧版本无济于事。

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)

The same thing happened to me.这样的事情我也经历过。 The problem was in the .npm folder that did not have the necessary permissions.问题出在没有必要权限的 .npm 文件夹中。 I ran the command:我运行了命令:

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

And everything went back to working normally一切都恢复正常

There was an issue opened about this, and here 's their solution:存在这样的问题开过这个问题, 这里是他们的解决方案:

sudo npm cache clean --force

The install went smoothly after that.之后安装很顺利。

In my case this was caused by having an ancient version of node in my project.在我的情况下,这是由于我的项目中有一个古老版本的节点引起的。 Updating the node version fixed it for me.更新节点版本为我修复了它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM