question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SyntaxError: Unexpected token '?'

See original GitHub issue

Hi! I’m attempting to use this on my Sapper project. I’m new to Svelte, so let me know if this is a dumb mistake.

I can’t seem to get this package to run without getthig the following error in my terminal:

[0] /www/public/sapper/osprey-sapper/site/__sapper__/dev/server/server.js:5694
[0]   const json = typeof(localStorage) != 'undefined' ?? localStorage.getItem(key);
[0]                                                     ^
[0] 
[0] SyntaxError: Unexpected token '?'
[0]     at wrapSafe (internal/modules/cjs/loader.js:1071:16)
[0]     at Module._compile (internal/modules/cjs/loader.js:1121:27)
[0]     at Object.Module._extensions..js (internal/modules/cjs/loader.js:1177:10)
[0]     at Module.load (internal/modules/cjs/loader.js:1001:32)
[0]     at Function.Module._load (internal/modules/cjs/loader.js:900:14)
[0]     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
[0]     at internal/main/run_main_module.js:18:47
[0] > Server crashed

My stores.js looks like this

import { writable } from 'svelte-local-storage-store'

export const theme = writable('theme','dark')

And then, once I drop this code in my component, is when I get the error

<script>
  import { theme } from '../../stores'

  ...

<div>{$theme}</div>

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
joshnusscommented, Aug 18, 2020

I reverted to using a regular conditional, and confirmed it’s working with the sveltejs/template. Update svelte-local-storage-store version to 0.1.3 and let me know if it’s still an issue.

0reactions
kenjonespizzacommented, Aug 18, 2020

Youre the 💣! Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

SyntaxError: Unexpected token - JavaScript - MDN Web Docs
The JavaScript exceptions "unexpected token" occur when a specific language construct was expected, but something else was provided.
Read more >
syntax error: unexpected token - javascript
The error SyntaxError: Unexpected token < likely means the API endpoint didn't return JSON in its document body, such as due to a...
Read more >
Have a JavaScript Unexpected Token Error? Check Your ...
Today, we are discussing the Unexpected Token Error within our JavaScript Error Handling series. This JavaScript error is a subset of the ...
Read more >
JavaScript SyntaxError - Unexpected token
This JavaScript exceptions unexpected token occur if a specific language construct was expected, but anything else is typed mistakenly.
Read more >
SyntaxError: Unexpected token in JavaScript
The "SyntaxError: Unexpected token" error in JavaScript is a common syntax error that occurs when the JavaScript interpreter encounters a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found