gpt4 book ai didi

svelte - 这个 vite 错误是什么意思?语法错误 : Unexpected token (6:180) at Object. pp$4.raise

转载 作者:行者123 更新时间:2023-12-04 03:30:10 25 4
gpt4 key购买 nike

我正在将我的 Sapper 应用程序升级到 SvelteKit。我可以正常运行 npm run dev 并在 localhost:3000 上启动我的应用程序。当我浏览到该 URL 时,出现以下错误:

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)

我无法弄清楚引发此错误的意义所在。谁能推荐一个地方看?

我的 svelte.config.cjs 是

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']
}
}
}
};

我的 package.json 包括以下内容

  "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"
}

最佳答案

我自己解决了这个错误。当我运行 npm run build 而不是 npm run dev 时,我发现了有关错误的更多细节。这指出错误在文件 $error.svelte 中。

因为我不需要自定义错误,所以我删除了那个页面,现在我可以在 localhost:3000 上访问我的网站了。

虽然我没有深入了解这一点,但我将其标记为正确,因为它揭示了错误的位置。

关于svelte - 这个 vite 错误是什么意思?语法错误 : Unexpected token (6:180) at Object. pp$4.raise,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67050786/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com