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.

2 Answers 2

1

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

{
   "port": "8001"
}
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks! I tried "port": 8001, but not both of them.
{ "port": 8001 } is valid JSON. The difference is that 8001 is a number value and "8001" is a string value, like in JavaScript.
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
}

1 Comment

add more details to it...possibly an explanation

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.