2017-01-19 48 views
1

我打開Atom時不斷收到此錯誤消息。我試圖找到它,但我似乎無法找到錯誤消息的位置?我錯過了JSON文件中的某些內容嗎?意外的令牌。找不到錯誤?

錯誤消息標題

無法加載的我的包包

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": { 
     } 
    } 
+0

http://jsonlint.com/ – Adam

回答

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": {} 
    } 
+0

感謝可惜它沒有工作 – Mohammad

+0

'依賴 「:{}'在哪裏匹配'」'是什麼? –

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