nodejs抛出JSON输入的意外结尾

时间:2019-01-17 11:47:58

标签: javascript node.js json

我将此代码导入到我的node js项目

const reputations = require("../../reputation.json");

然后我尝试运行node .,因此出现错误

module.js:674
    throw err;
    ^

SyntaxError: /home/ghost/Desktop/learn/git/bot/reputation.json: Unexpected end of JSON input
    at JSON.parse (<anonymous>)
    at Object.Module._extensions..json (module.js:671:27)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/ghost/Desktop/learn/git/bot/commands/simple/rep.js:2:21)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)

但我不知道这里哪里出了错

  

JSON输入意外结束

但是我喜欢扩展名是正确的,并且导入方式也正确,那么为什么会出错?

一些更苗条的问题无法解决我的问题

  1. npm ERR! Unexpected end of JSON input while parsing
  2. npm ERR! Unexpected end of JSON input
  3. ERROR Unexpected end of JSON , input Unexpected end of JSON input
  4. Uncaught SyntaxError: Unexpected end of JSON input [}

注释

npm版本5.8.0

节点版本8.11.4

这是文件名reputation.json

enter image description here

1 个答案:

答案 0 :(得分:0)

请使用下面的链接并检查您的JSON是否正确http://json.parser.online.fr/