当我 运行 NPM live-server 时出现错误

Getting an error when I run NPM live-server

这是我正在使用的服务器,https://www.npmjs.com/package/live-server。然而,当我尝试使用 ~/.live-server.json 作为配置文件时,我总是失败......这是我在文件中的内容,它非常简单。

{
   port: "8001"
}

然后我在 运行 live-server

时出现这个错误
undefined:2
   port: "8001"
   ^    

SyntaxError: Unexpected token p
    at Object.parse (native)
    at Object.<anonymous> (/usr/local/lib/node_modules/live-server/live-server.js:17:20)
    at Module._compile (module.js:435:26)
    at Object.Module._extensions..js (module.js:442:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:311:12)
    at Function.Module.runMain (module.js:467:10)
    at startup (node.js:136:18)
    at node.js:963:3

我不知道为什么会这样。

属性 JSON 中的名称必须用引号引起来(JSON 不是 JavaScript):

{
   "port": "8001"
}

应该是:

{
    "port": 8001
}

添加说明:好吧,在JSON中,名称应该始终用双引号引起来,值也应该用双引号引起来,数字除外(如果将数字用双引号引起来,它就会变成一个字符串)。像这样:

{
    "name1": "stringValue",
    "name2": aNumber
}