Reputation: 1108
I was about to use live-server and I got this error when I followed the instructions to set up ~/.live-server.json
undefined:1
var liveServer = require("live-server");
^
SyntaxError: Unexpected token v in JSON at position 0
at JSON.parse (<anonymous>)
at Object.<anonymous> (/usr/local/lib/node_modules/live-server/live-server.js:20:20)
Does this mean var
cannot be contained in a JSON file?
Upvotes: 3
Views: 3863
Reputation: 669
No, you cannot use var in a JSON file and you can't call any function (like require). JSON is just a format to represent data.
I just looked into the documentation very briefly but as I understand it you can define options in this JSON file that are then used by live-server. In this case you don't have to specify them in your js file. But in every case you have to require and start live-server inside of a JavaScript file.
Upvotes: 0
Reputation: 7204
var liveServer = require("live-server");
It means that you required npm module live-server
. You don't assign json to var liveServer
.
And when you require this module it loads and parse json file ~/.live-server.json
Your error means that your json file isn't in correct json format - you have bug there.
Please paste your json to any json validator (for example http://jsonlint.com/) and fix issues.
Upvotes: 1