sveltejs / kit

web development, streamlined
https://kit.svelte.dev
MIT License
18.61k stars 1.92k forks source link

wide_align node_module from adapter-vercel blocking node.js 20 deployment compatibility on vercel edge #11514

Closed vyconm closed 9 months ago

vyconm commented 9 months ago

Describe the bug

When trying to build with Node.js 20 on Vercel with svelteKit 2.0.4 the following errror throws up:

error during build:
Error [ERR_REQUIRE_ESM]: require() of ES Module /vercel/path0/node_modules/string-width/index.js from /vercel/path0/node_modules/wide-align/align.js not supported.
Instead change the require of index.js in /vercel/path0/node_modules/wide-align/align.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/vercel/path0/node_modules/wide-align/align.js:2:19)
    at Object.<anonymous> (/vercel/path0/node_modules/gauge/render-template.js:2:13)
    at Object.<anonymous> (/vercel/path0/node_modules/gauge/plumbing.js:3:22)
    at Object.<anonymous> (/vercel/path0/node_modules/gauge/index.js:2:16)
    at Object.<anonymous> (/vercel/path0/node_modules/npmlog/log.js:3:13)
    at Object.<anonymous> (/vercel/path0/node_modules/@mapbox/node-pre-gyp/lib/node-pre-gyp.js:23:13)
    at Object.<anonymous> (/vercel/path0/node_modules/@vercel/nft/out/analyze.js:22:40)
    at Object.<anonymous> (/vercel/path0/node_modules/@vercel/nft/out/node-file-trace.js:31:35)
    at Object.<anonymous> (/vercel/path0/node_modules/@vercel/nft/out/index.js:22:25)
    at async load_config (file:///vercel/path0/node_modules/@sveltejs/kit/src/core/config/index.js:70:17)
    at async sveltekit (file:///vercel/path0/node_modules/@sveltejs/kit/src/exports/vite/index.js:130:24)
    at async Promise.all (index 0)
    at async asyncFlatten (file:///vercel/path0/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:12894:16)
    at async resolveConfig (file:///vercel/path0/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:67500:29)
    at async build (file:///vercel/path0/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:66647:20)
    at async CAC.<anonymous> (file:///vercel/path0/node_modules/vite/dist/node/cli.js:845:9)
error: script "build" exited with code 1 (SIGHUP)

running npm why wide-align reveals the following:

wide-align@1.1.5
node_modules/wide-align
  wide-align@"^1.1.2" from gauge@3.0.2
  node_modules/gauge
    gauge@"^3.0.0" from npmlog@5.0.1
    node_modules/npmlog
      npmlog@"^5.0.1" from @mapbox/node-pre-gyp@1.0.11
      node_modules/@mapbox/node-pre-gyp
        @mapbox/node-pre-gyp@"^1.0.5" from @vercel/nft@0.26.2
        node_modules/@vercel/nft
          @vercel/nft@"^0.26.1" from @sveltejs/adapter-vercel@4.0.4
          node_modules/@sveltejs/adapter-vercel
            @sveltejs/adapter-vercel@"^4.0.4" from the root project

Reproduction

Cloning github.com/PivotMasterNM/skeletonUIcli_lybsHome (Branch: main, Commit: 9e7832d) Cloning completed: 885.713ms Skipping build cache since Node.js version changed from "18.x" to "20.x" Running "vercel build" Vercel CLI 33.0.1

Logs

Running build in Washington, D.C., USA (East) – iad1
--
Cloning github.com/PivotMasterNM/skeletonUIcli_lybsHome (Branch: main, Commit: 9e7832d)
Cloning completed: 885.713ms
Skipping build cache since Node.js version changed from "18.x" to "20.x"
Running "vercel build"
Vercel CLI 33.0.1
Running "install" command: `bun install`...
bun install v1.0.6 (969da088)
+ @playwright/test@1.40.1
+ @skeletonlabs/skeleton@2.7.0
+ @skeletonlabs/tw-plugin@0.3.1
+ @sveltejs/adapter-auto@3.0.1
+ @sveltejs/kit@2.0.6
+ @sveltejs/vite-plugin-svelte@3.0.1
+ @tailwindcss/forms@0.5.7
+ @tailwindcss/typography@0.5.10
+ @types/eslint@8.56.1
+ @types/node@20.10.6
+ @typescript-eslint/eslint-plugin@6.17.0
+ @typescript-eslint/parser@6.17.0
+ autoprefixer@10.4.16
+ eslint@8.56.0
+ eslint-config-prettier@9.1.0
+ eslint-plugin-svelte@2.35.1
+ postcss@8.4.32
+ prettier@3.1.1
+ prettier-plugin-svelte@3.1.2
+ svelte@4.2.8
+ svelte-check@3.6.2
+ svelte-reveal@0.7.0
+ tailwindcss@3.4.0
+ tslib@2.6.2
+ typescript@5.3.3
+ vite@5.0.10
+ vite-plugin-tailwind-purgecss@0.2.0
+ vitest@1.1.1
+ @sveltejs/adapter-vercel@4.0.3
+ @vercel/speed-insights@1.0.2
 
393 packages installed [860.00ms]
$ vite build
▲ [WARNING] Cannot find base config file "./.svelte-kit/tsconfig.json" [tsconfig.json]
 
tsconfig.json:2:12:
2 │   "extends": "./.svelte-kit/tsconfig.json",
╵              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

error during build:
Error [ERR_REQUIRE_ESM]: require() of ES Module /vercel/path0/node_modules/string-width/index.js from /vercel/path0/node_modules/wide-align/align.js not supported.
Instead change the require of index.js in /vercel/path0/node_modules/wide-align/align.js to a dynamic import() which is available in all CommonJS modules.
    at Object.<anonymous> (/vercel/path0/node_modules/wide-align/align.js:2:19)
    at Object.<anonymous> (/vercel/path0/node_modules/gauge/render-template.js:2:13)
    at Object.<anonymous> (/vercel/path0/node_modules/gauge/plumbing.js:3:22)
    at Object.<anonymous> (/vercel/path0/node_modules/gauge/index.js:2:16)
    at Object.<anonymous> (/vercel/path0/node_modules/npmlog/log.js:3:13)
    at Object.<anonymous> (/vercel/path0/node_modules/@mapbox/node-pre-gyp/lib/node-pre-gyp.js:23:13)
    at Object.<anonymous> (/vercel/path0/node_modules/@vercel/nft/out/analyze.js:22:40)
    at Object.<anonymous> (/vercel/path0/node_modules/@vercel/nft/out/node-file-trace.js:31:35)
    at Object.<anonymous> (/vercel/path0/node_modules/@vercel/nft/out/index.js:22:25)
    at async load_config (file:///vercel/path0/node_modules/@sveltejs/kit/src/core/config/index.js:70:17)
    at async sveltekit (file:///vercel/path0/node_modules/@sveltejs/kit/src/exports/vite/index.js:130:24)
    at async Promise.all (index 0)
    at async asyncFlatten (file:///vercel/path0/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:12894:16)
    at async resolveConfig (file:///vercel/path0/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:67500:29)
    at async build (file:///vercel/path0/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:66647:20)
    at async CAC.<anonymous> (file:///vercel/path0/node_modules/vite/dist/node/cli.js:845:9)
error: script "build" exited with code 1 (SIGHUP)
Error: Command "bun run build" exited with 1

### System Info

```Shell
System:
    OS: macOS 14.2.1
    CPU: (10) arm64 Apple M1 Max
    Memory: 2.39 GB / 64.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 21.2.0 - /usr/local/bin/node
    npm: 10.2.3 - /usr/local/bin/npm
    bun: 1.0.21 - ~/.bun/bin/bun
  Browsers:
    Chrome: 120.0.6099.129
    Safari: 17.2.1
  npmPackages:
    @sveltejs/adapter-auto: ^3.1.0 => 3.1.0 
    @sveltejs/adapter-vercel: ^4.0.4 => 4.0.4 
    @sveltejs/kit: ^2.0.6 => 2.0.6 
    @sveltejs/vite-plugin-svelte: ^3.0.1 => 3.0.1 
    svelte: ^4.2.8 => 4.2.8 
    vite: ^5.0.10 => 5.0.10

Severity

blocking an upgrade

Additional Information

No response

dummdidumm commented 9 months ago

Did this work previously?

Also, please provide a minimal reproduction repository (the one you linked is a 404 for me, and likely not a minimum reproduction).

vyconm commented 9 months ago

follow up:

Switching from bun install manually to npm install on vercel's deployment settings fixed this, which is odd. Building locally with bun didn't pose any issues.

This might be relatated to vercels CLI tool after all.