Create Daml app Unknown error Syntaxerror: unexpected token E in JSON at position 0

I just finished updating my version of the DAML SDK to the latest and when I attempt to login to the Navigator. This is when using the create daml app, I get the following error message:
Unknown error Syntaxerror: unexpected token E in JSON at position 0

What is causing this? Has anyone else had this?

Any suggestions would be great?

Edit: sorry for not being clear at first

this is my URL http://localhost:3000/
I am following the crate daml app tutorial.

I could not find the navigator.log I apologize not sure where to find it

Sandbox.log

12:41:38.374 [sandbox-akka.actor.default-dispatcher-5] INFO akka.event.slf4j.Slf4jLogger - Slf4jLogger started
12:41:43.440 [pool-1-thread-4] INFO c.d.p.apiserver.LedgerApiServer - Listening on localhost:6865 over plain text.
12:41:43.448 [pool-1-thread-2] INFO com.daml.platform.sandboxnext.Runner - Initialized sandbox version 1.7.0 with ledger-id = create-daml-app-sandbox, port = 6865, dar file = List(.daml\dist\create-daml-app-0.1.0.dar), time mode = wall-clock time, ledger = in-memory, auth-service = AuthServiceWildcard$, contract ids seeding = strong

I didn’t see any errors in my dev console

1 Like

Do you get this error when you try starting the UI by doing:

cd ui/
npm install
npm run-script build
npm start

And using the UI that comes with create-daml-app (as opposed to Navigator)?

1 Like

Hi @davidk, I saw you posted the same question on Stackoverflow. Same request as I left there, we need a bit more information to diagnose this:

Could you share the command you use to start the Navigator, and the log outputs? By default they’d be in navigator.log and sandbox.log . Also, what URL do you get that error on? You could also try opening your browser’s developer console and checking whether there are any requests with error codes and if so, share those here.

The type of error unexpected token E in JSON at position 0 tends to occur when a webapp calls an endpoint which it expects to return a JSON payload, but instead it gets something different like a HTML error page. My best guess is that there was a port mismatch and something other than the Navigator was running on the port that was being called.

2 Likes

I think you forgot to start DAML mode… Try daml start

2 Likes

I got the same issue because I was running an older version of Java (i.e. 8), but daml requires 11. It’s a little confusing that we get a JS error because npm start does not print out an error message and happily starts up. It’s nice :pray: if user errors are detected and useful messages are printed rather than allowing an app to run in an inconsistent state / badly configured environment.

Would be nice if :pray:

  • npm start refuses to start and prints an error message if daml is not running as expected, this would have prevented the above user hitting this issue and also myself.
  • Digital Asset implement version handshakes so that meaningful error messages are produced.
  • daml start exits rather than continuing to run when the java version is incorrect

Anyway to fix I had to do the following:

brew install java11

This doesn’t seem to do anything:

sam@MacBook-Pro:/Users/sam/src/create-daml-app ls /Library/Java/JavaVirtualMachines/
jdk1.8.0_192.jdk

reading the brew logs I see a message about

/usr/local/Cellar/openjdk@11/11.0.12/bin/java

So then running:

export JAVA_HOME=/usr/local/Cellar/openjdk@11/11.0.12

means now I get

sam@MacBook-Pro:/Users/sam/src/create-daml-app java -version
openjdk version "11.0.12" 2021-07-20
OpenJDK Runtime Environment Homebrew (build 11.0.12+0)
OpenJDK 64-Bit Server VM Homebrew (build 11.0.12+0, mixed mode)

Killing and rerunning daml start and npm start solves the error in the OP

1 Like