SyntaxError: Unexpected token '?'
See original GitHub issueHi! 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:
- Created 3 years ago
- Comments:5 (3 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I reverted to using a regular conditional, and confirmed it’s working with the
sveltejs/template
. Updatesvelte-local-storage-store
version to0.1.3
and let me know if it’s still an issue.Youre the 💣! Thanks!