Unexpected token n JSON at position
Closed this issue · 2 comments
michaelbromley commented
When attempting to create a new node, I get the following error:
demo:82f3b9dc81064ffeb3b9dc81061ffe73$ create
Multiline input: terminate with ";;⏎"
> { "schema": { "name": "vehicle" }, "parentNodeUuid": "6ade18e92abd464c9e18e92abd864c42", "language": "en" }
> ;;
ERROR SyntaxError: Unexpected token n JSON at position 89
at Object.parse (native)
at C:\Program Files (x86)\Nodist\bin\node_modules\mesh-cli\build\commands\create.js:13:25
at next (native)
at C:\Program Files (x86)\Nodist\bin\node_modules\mesh-cli\build\commands\create.js:7:71
at __awaiter (C:\Program Files (x86)\Nodist\bin\node_modules\mesh-cli\build\commands\create.js:3:12)
at create (C:\Program Files (x86)\Nodist\bin\node_modules\mesh-cli\build\commands\create.js:11:12)
at C:\Program Files (x86)\Nodist\bin\node_modules\mesh-cli\build\commands.js:46:27
at next (native)
at C:\Program Files (x86)\Nodist\bin\node_modules\mesh-cli\build\commands.js:15:71
at __awaiter (C:\Program Files (x86)\Nodist\bin\node_modules\mesh-cli\build\commands.js:11:12)
Perhaps this is due to some difference in the Windows-style line endings.
cprerovsky commented
Hey,
hm, thats super weird. I built it to work with Windows line endings, so that this should NOT occur - seems it didn't work out. The actual implementation is:
let input = state.buffer.join('\n');
let data = JSON.parse(input.substr(input.indexOf('{')));
where state.buffer in your case is:
['create', '{ "schema": { "name": "vehicle" }, "parentNodeUuid": "6ade18e92abd464c9e18e92abd864c42", "language": "en" }']
Could you quickly run that code on your machine to see whether it produces that error?
Thanks!
michaelbromley commented
I can run the above code in both Chrome and Node (v6.3.0) and it works as expected.