简体   繁体   English

package.json实际上使用JSON,而不仅仅是JavaScript

[英]package.json actually in JSON, not just JavaScript

I keep on getting this on my Heroku log "npm ERR! package.json must be actual JSON, not just JavaScript." 我继续在Heroku日志中获取“ npm ERR!package.json必须是实际的JSON,而不仅仅是JavaScript。” Here's my package.json file which I thought was in correct JSON until now. 这是我的package.json文件,到目前为止,我认为它是正确的JSON。 Please help. 请帮忙。

{
    "name": "GWC-Final-Project",
    "version": "0.0.0",
    "private": true,
    "description": "Girls Who Code web-app",
    "main": "web.js"
}{
    "dependencies": {
        "body-parser": "~1.15.1",
        "cookie-parser": "~1.4.3",
        "debug": "~2.2.0",
        "express": "^4.10.2",
        "hbs": "~4.0.0",
        "morgan": "~1.7.0",
        "serve-favicon": "~2.3.0",
        "socket.io": "^1.4.8"
    }
}

All npm packages contain a file, usually in the project root, called 所有npm软件包都包含一个文件,通常在项目根目录中,该文件称为

package.json - this file holds various metadata relevant to the project. package.json-该文件包含与项目相关的各种元数据。 This file is used to give information to npm that allows it to identify the project as well as handle the project's dependencies. 该文件用于向npm提供信息,以使其能够识别项目并处理项目的依赖关系。

It must be actual JSON, not just a JavaScript object literal. 它必须是实际的JSON,而不仅仅是JavaScript对象文字。

Json is built on two structures: Json建立在两个结构上:

  • A collection of name/value pairs. 名称/值对的集合。 In various languages, this is realized as an object, record, struct, dictionary, hash table, keyed list, or associative array. 在各种语言中,这被实现为对象,记录,结构,字典,哈希表,键列表或关联数组。
  • An ordered list of values. 值的有序列表。 In most languages, this is realized as an array, vector, list, or sequence. 在大多数语言中,这是通过数组,向量,列表或序列来实现的。

Corrected package.json file : 更正了package.json文件:

{
    "name": "GWC-Final-Project",
    "version": "0.0.0",
    "private": true,
    "description": "Girls Who Code web-app",
    "main": "web.js"
    "dependencies": {
        "body-parser": "~1.15.1",
        "cookie-parser": "~1.4.3",
        "debug": "~2.2.0",
        "express": "^4.10.2",
        "hbs": "~4.0.0",
        "morgan": "~1.7.0",
        "serve-favicon": "~2.3.0",
        "socket.io": "^1.4.8"
    }
}

You're missing a comma between }{ 您在}{之间缺少逗号

{
"name": "GWC-Final-Project",
"version": "0.0.0",
"private": true,
"description": "Girls Who Code web-app",
"main": "web.js"
},
{
"dependencies": {
    "body-parser": "~1.15.1",
    "cookie-parser": "~1.4.3",
    "debug": "~2.2.0",
    "express": "^4.10.2",
    "hbs": "~4.0.0",
    "morgan": "~1.7.0",
    "serve-favicon": "~2.3.0",
    "socket.io": "^1.4.8"
}
}

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

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