I am upgrading my Sapper application to SvelteKit. I can run npm run dev fine and it starts my application on localhost:3000. When I browse to that URL, I get the following error:
SyntaxError: Unexpected token (6:180)
at Object.pp$4.raise (../node_modules/vite/dist/node/chunks/dep-66eb515d.js:35308:13)
at Object.pp.unexpected (../node_modules/vite/dist/node/chunks/dep-66eb515d.js:32999:8)
at Object.pp.expect (../node_modules/vite/dist/node/chunks/dep-66eb515d.js:32993:26)
at Object.pp$3.parseObj (../node_modules/vite/dist/node/chunks/dep-66eb515d.js:34944:12)
at Object.pp$3.parseExprAtom (../node_modules/vite/dist/node/chunks/dep-66eb515d.js:34683:17)
at Object.pp$3.parseExprSubscripts (../node_modules/vite/dist/node/chunks/dep-66eb515d.js:34509:19)
at Object.pp$3.parseMaybeUnary (../node_modules/vite/dist/node/chunks/dep-66eb515d.js:34486:17)
at Object.parseMaybeUnary (../node_modules/vite/dist/node/chunks/dep-66eb515d.js:43031:29)
at Object.pp$3.parseExprOps (../node_modules/vite/dist/node/chunks/dep-66eb515d.js:34421:19)
at Object.pp$3.parseMaybeConditional (../node_modules/vite/dist/node/chunks/dep-66eb515d.js:34404:19)
I can't figure out the point this error is being raised. Can anyone suggest a place to look?
My svelte.config.cjs is
const node = require('@sveltejs/adapter-node');
module.exports = {
kit: {
// By default, `npm run build` will create a standard Node app.
// You can create optimized builds for different platforms by
// specifying a different adapter
adapter: node(),
// hydrate the <div id="svelte"> element in src/app.html
target: '#svelte',
vite: {
ssr: {
noExternal: ['node-fetch']
}
}
}
};
My package.json includes the follows
"dependencies": {
"typescript": "^4.2.4",
"node-fetch": "^2.6.1",
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.5"
},
"devDependencies": {
"@sveltejs/kit": "next",
"vite": "^2.1.5",
"@sveltejs/adapter-node": "next",
"svelte": "^3.35.0",
"svelte-flex": "^1.2.2",
"svelte-simple-modal": "^0.9.0"
}
I was able to resolve this error myself. I found more specifics on the error when I ran npm run build instead of npm run dev. This pointed out the error was in the file $error.svelte.
Since I didn't need a custom error, I deleted that page and now I am able to access my site on localhost:3000.
Although I didn't get to the bottom of this I am marking this correct as it revealed the location of the error.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With