意外的标记。找不到错误?

时间:2017-01-19 21:27:35

标签: json unexpected-token

当我打开Atom时,我一直收到此错误消息。我试过调查但我似乎无法找到错误信息的位置?我错过了JSON文件中的内容吗?

错误讯息标题

无法加载my-package包

untitled1:1
LFUTF-8Plain Text
Failed to load the my-package package
Unexpected token } in JSON at position 160 in /Users/tech-a48/.atom/packages/my-package/package.json
Hide Stack Trace
SyntaxError: Unexpected token } in JSON at position 160
    at Object.parse (native)
    at parseObject (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/season/lib/cson.js:54:19)
    at parseContentsSync (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/season/lib/cson.js:68:16)
    at Object.readFileSync (/Applications/Atom.app/Contents/Resources/app.asar/node_modules/season/lib/cson.js:170:14)
    at PackageManager.module.exports.PackageManager.loadPackageMetadata (/Applications/Atom.app/Contents/Resources/app.asar/src/package-manager.js:721:29)
    at PackageManager.module.exports.PackageManager.loadPackage (/Applications/Atom.app/Contents/Resources/app.asar/src/package-manager.js:434:35)
    at /Applications/Atom.app/Contents/Resources/app.asar/src/package-manager.js:412:19
    at Config.module.exports.Config.transact (/Applications/Atom.app/Contents/Resources/app.asar/src/config.js:312:16)
    at PackageManager.module.exports.PackageManager.loadPackages (/Applications/Atom.app/Contents/Resources/app.asar/src/package-manager.js:407:19)
    at /Applications/Atom.app/Contents/Resources/app.asar/src/atom-environment.js:811:28
  at /Users/tech-a48/.atom/packages/my-package/package.json:1:1

这是JSON文件。我完全失明了还是我错过了什么?

        {
      "name": "my-package",
      "main": "./lib/my-package",
      "version": "0.0.0",
      "description": "A short description of your package",
      "keywords": [
      ],

      },
      {
      "repository": "https://github.com/atom/my-package",
      "license": "MIT",
      "engines": {
        "atom": ">=1.0.0 <2.0.0"
      },
      "dependencies": {
      }
    }

3 个答案:

答案 0 :(得分:0)

试试这个,它可能会有所帮助:

{
  "name": "my-package",
  "main": "./lib/my-package",
  "version": "0.0.0",
  "description": "A short description of your package",
  "keywords": []
  },
  {
  "repository": "https://github.com/atom/my-package",
  "license": "MIT",
  "engines": 
      {
        "atom": ">=1.0.0 <2.0.0"
      }
 }, 
  { 
    "dependencies": {}
  }

答案 1 :(得分:0)

嗨伙计问题是因为JSON文件的结构错误。 试试吧。

{
  "name": "my_package",
  "version": "1.0.0",
  "main": "index.js",
  "scripts": {
    "test": "echo"
  },
  "keywords": [],
  "author": "ag_dubs",
  "license": "ISC",
  "repository": {
    "type": "git",
    "url": "https://github.com/someone/my_package.git"
  },
  "bugs": {
    "url": "https://github.com/someone/my_package/issues"
  },
  "homepage": "https://github.com/someone/my_package"
}

答案 2 :(得分:0)

这对我们进行故障排除非常困难,因为您的对象结构不正确。这是一个有效的json对象。 (这可能不正确)

{
    "name": "my-package",
    "main": "./lib/my-package",
    "version": "0.0.0",
    "description": "A short description of your package",
    "keywords": [],
    "repository": "https://github.com/atom/my-package",
    "license": "MIT",
    "engines": {
        "atom": ">=1.0.0 <2.0.0"
    },
    "dependencies": {}
}

您的代码首先显示不完整的json,因此我假设您要在顶部添加{。对象必须是可重现的。您提供的json不可重复,如下所示。

{
     {
      "name": "my-package",
      "main": "./lib/my-package",
      "version": "0.0.0",
      "description": "A short description of your package",
      "keywords": [
      ],

      }, //this indicates you are ending the object that has the "name" property
        //but then look below, now your next object doesn't start with a name property. 
       //If you truly want separate objects. You should name each of them, so they are properties of the parent.
      {
      "repository": "https://github.com/atom/my-package",
      "license": "MIT",
      "engines": {
        "atom": ">=1.0.0 <2.0.0"
      },
      "dependencies": {
      }
}