0

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

I don't know why this is happening.

TylerH
  • 20,799
  • 66
  • 75
  • 101
Bomin
  • 1,619
  • 5
  • 24
  • 39

2 Answers2

1

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

{
   "port": "8001"
}
Jordan Running
  • 102,619
  • 17
  • 182
  • 182
0

It should be:

{
    "port": 8001
}

Add explanation: well, in JSON, name should always double quoted, and value should also be double quoted, except number (if you double quote a number, it becomes a string). Like this:

{
    "name1": "stringValue",
    "name2": aNumber
}
alexcres
  • 53
  • 2
  • 12