![](/img/trans.png)
[英]Getting error while installing live-server package using npm. `npm audit` is not helping to fix the problem
[英]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
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.