I just tried this project. Installed it via npm install -g and tried the example db.json. It errors out... Am I doing something wrong?
root@ntc:/vagrant/tftpboot# json-server --watch db.json
/usr/local/lib/node_modules/json-server/lib/cli/index.js:9
updateNotifier({ pkg }).notify();
^
SyntaxError: Unexpected token }
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
Hi @termlen0,
Can you check your version of Node?
JSON Server requires Node 4+ (https://github.com/typicode/json-server/blob/master/package.json#L92)
That was it! Thanks. Wonder if it makes sense to add that to the install instructions (for non node developers/users like me )
Good point.
Normally, npm should warn users if they try to install with a Node version that doesn't match the engine field:
npm WARN engine [email protected]: wanted: {"node":">= 4"} (current: {"node":"0.12.18","npm":"2.15.11"})
But in practice, people tend to miss it or, as you said, if they're new it may not be explicit enough.
That said, other CLI tend to not explicitly mention it in their README either, and Node 0.12 is deprecated, so I'll probably leave it as it is for now as there should be less users running 0.12 in the long run.
@typicode thank you~I already konw what's problem, hhha
@termlen0 after giving some more thoughts and research, let's be beginner-friendly.
I've published please-upgrade-node this week-end and added it to JSON Server v0.11.2.
I'll add it to my other projects too.
Thank you for the suggestion :+1:
Awesome! thanks
In my case Json server is installed but unable to start with '$' as throws error '$' is not recognize.
Most helpful comment
Good point.
Normally,
npmshould warn users if they try to install with a Node version that doesn't match theenginefield:But in practice, people tend to miss it or, as you said, if they're new it may not be explicit enough.
That said, other CLI tend to not explicitly mention it in their README either, and Node 0.12 is deprecated, so I'll probably leave it as it is for now as there should be less users running 0.12 in the long run.