【问题标题】:Build fails with latest version of vite, vercel-adapter and sveltekit使用最新版本的 vite、vercel-adapter 和 sveltekit 构建失败
【发布时间】:2022-10-23 18:12:17
【问题描述】:

我已将我的 npm 依赖项更新为最新版本,现在我无法创建构建。我得到的错误是转换失败,出现 2 个错误:未终止的字符串标记.我检查了我的 HTML 文件,其中大部分 CSS 类是内联的,因为我使用的是 tailwind CSS,但所有文件都在一行中包含类。我无法找出问题所在。

我的 package.json

"devDependencies": {
        "@playwright/test": "^1.19.1",
        "@sveltejs/adapter-vercel": "^1.0.0-next.47",
        "@sveltejs/kit": "next",
        "@tailwindcss/line-clamp": "^0.3.1",
        "@typescript-eslint/eslint-plugin": "^5.10.1",
        "@typescript-eslint/parser": "^5.10.1",
        "autoprefixer": "^10.4.2",
        "eslint": "^7.32.0",
        "eslint-config-prettier": "^8.3.0",
        "eslint-plugin-svelte3": "^3.2.1",
        "postcss": "^8.4.5",
        "postcss-load-config": "^3.1.1",
        "prettier": "^2.5.1",
        "prettier-plugin-svelte": "^2.5.0",
        "svelte": "^3.44.0",
        "svelte-check": "^2.2.6",
        "svelte-preprocess": "^4.10.1",
        "tailwindcss": "^3.0.12",
        "tslib": "^2.3.1",
        "typescript": "~4.6.2"
    },
    "type": "module",
    "dependencies": {
        "@floating-ui/dom": "^0.4.4",
        "cookie": "^0.4.2",
        "notyf": "^3.10.0",
        "swiper": "^8.0.7",
        "ts-results": "^3.3.0"
    }
    

日志

rendering chunks (7)...[vite:css-post] Transform failed with 2 errors:
<stdin>:1:73: ERROR: Unterminated string token
<stdin>:2:55: ERROR: Unterminated string token
> Transform failed with 2 errors:
<stdin>:1:73: ERROR: Unterminated string token
<stdin>:2:55: ERROR: Unterminated string token
<stdin>:1:73: ERROR: Unterminated string token
<stdin>:2:55: ERROR: Unterminated string token
    at failureErrorWithLog (E:\StoreBud\storebud-storefront\node_modules\esbuild\lib\main.js:1603:15)
    at E:\StoreBud\storebud-storefront\node_modules\esbuild\lib\main.js:1392:29
    at E:\StoreBud\storebud-storefront\node_modules\esbuild\lib\main.js:666:9
    at handleIncomingPacket (E:\StoreBud\storebud-storefront\node_modules\esbuild\lib\main.js:763:9)
    at Socket.readFromStdout (E:\StoreBud\storebud-storefront\node_modules\esbuild\lib\main.js:632:7)
    at Socket.emit (events.js:376:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at Socket.Readable.push (internal/streams/readable.js:223:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)

【问题讨论】:

    标签: svelte vite sveltekit


    【解决方案1】:

    原来这个问题是由于 npx svelte-add@latest tailwindcss 项目添加的 app.css 文件导致的,该文件用于将 tailwind CSS 添加到 sveltekit。具体来说,问题是由 app.css 顶部添加的评论引起的。删除评论后,我能够成功构建项目。

    【讨论】:

      【解决方案2】:

      当遇到这样的错误时,它也有助于碰撞@sveltejs/kit

      我在 GitHub 问题上搜索错误消息 TypeError: builder.getAppPath is not a function 以及随附的解决方案时发现:https://github.com/sveltejs/kit/issues/7284#issuecomment-1281026050

      【讨论】:

        猜你喜欢
        • 2021-06-14
        • 2021-11-23
        • 2022-09-23
        • 1970-01-01
        • 1970-01-01
        • 2022-12-07
        • 1970-01-01
        • 2018-02-12
        • 2021-12-30
        相关资源
        最近更新 更多