为什么package.json实际上是JSON,而不仅是JavaScript呢?

内容来源于 Stack Overflow,并遵循CC BY-SA 3.0许可协议进行翻译与使用

  • 回答 (2)
  • 关注 (0)
  • 查看 (48)

有以下代码:

{
    "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"
    }
}
提问于
用户回答回答于

更正后的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"
    }
}
用户回答回答于

你在}{之间少了一个逗号

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

扫码关注云+社区

领取腾讯云代金券