1

打开 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": {
      }
    }
4

3 回答 3

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": {}
  }
于 2017-01-19T21:31:39.333 回答
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"
}
于 2017-01-19T22:04:52.903 回答
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": {
      }
}
于 2017-01-19T22:29:03.370 回答