Bomin Bomin - 5 months ago 70
Node.js Question

NPM live-server

Here's the server I'm using, https://www.npmjs.com/package/live-server. However, when I try to use

~/.live-server.json
as the configuration file, I always fail... Here's what I have in the file, and it's very simple.

{
port: "8001"
}


Then I have this error when I run
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


Don't know why this is happening.

Answer

Property names in JSON must be quoted (JSON is not JavaScript):

{
   "port": "8001"
}
Comments