[英]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.