Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vite cannot load vite.config.ts with Node 17 and vite@4.4.0-beta.3 #13631

Closed
7 tasks done
brillout opened this issue Jun 25, 2023 · 9 comments
Closed
7 tasks done

Vite cannot load vite.config.ts with Node 17 and vite@4.4.0-beta.3 #13631

brillout opened this issue Jun 25, 2023 · 9 comments

Comments

@brillout
Copy link
Contributor

Describe the bug

When running $ vite build Vite throws this error:

$ pnpm build

> @ build /home/rom/tmp/vite-ssr-project
> vite build

failed to load config from /home/rom/tmp/vite-ssr-project/vite.config.ts
error during build:
Error: The URL must be of scheme file at /home/rom/tmp/vite-ssr-project/vite.config.ts
    at loadConfigFromBundledFile (file:///home/rom/tmp/vite-ssr-project/node_modules/.pnpm/vite@4.4.0-beta.3_@types+node@18.16.18/node_modules/vite/dist/node/chunks/dep-64acfab2.js:65812:19)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async loadConfigFromFile (file:///home/rom/tmp/vite-ssr-project/node_modules/.pnpm/vite@4.4.0-beta.3_@types+node@18.16.18/node_modules/vite/dist/node/chunks/dep-64acfab2.js:65661:28)
    at async resolveConfig (file:///home/rom/tmp/vite-ssr-project/node_modules/.pnpm/vite@4.4.0-beta.3_@types+node@18.16.18/node_modules/vite/dist/node/chunks/dep-64acfab2.js:65265:28)
    at async build (file:///home/rom/tmp/vite-ssr-project/node_modules/.pnpm/vite@4.4.0-beta.3_@types+node@18.16.18/node_modules/vite/dist/node/chunks/dep-64acfab2.js:47494:20)
    at async CAC.<anonymous> (file:///home/rom/tmp/vite-ssr-project/node_modules/.pnpm/vite@4.4.0-beta.3_@types+node@18.16.18/node_modules/vite/dist/node/cli.js:812:9)
 ELIFECYCLE  Command failed with exit code 1.

Reproduction

https://github.com/brillout/vite-reproduction-cannot-load-config

Steps to reproduce

See readme of reproduction.

System Info

System:
    OS: Linux 4.14 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
    CPU: (2) x64 Intel(R) Celeron(R) N4020 CPU @ 1.10GHz
    Memory: 102.18 MB / 3.72 GB
    Container: Yes
    Shell: 5.1.4 - /bin/bash
  Binaries:
    Node: 17.9.1 - ~/.nvm/versions/node/v17.9.1/bin/node
    npm: 8.11.0 - ~/.nvm/versions/node/v17.9.1/bin/npm
  npmPackages:
    @vitejs/plugin-react: ^3.0.0 => 3.1.0 
    vite: 4.4.0-beta.3 => 4.4.0-beta.3

Used Package Manager

pnpm

Logs

No response

Validations

@sapphi-red
Copy link
Member

I guess this is related to nodejs/node#42860.
The fixes was released in Node.js 16.17.0 and Node.js 18.1.0. But Node.js 17.x didn't have a fix because Node.js 17 EOL-ed in 2022-06 (The issue was reported in 2022-08).

We should have dropped Node.js 17 in Vite 3 (2022-07) or Vite 4.
https://vitejs.dev/blog/announcing-vite3.html#compatibility-notes

Or maybe we can already say we don't support Node.js 17 as we setup the release page.
https://vitejs.dev/releases.html#node-js-non-lts-versions

refs #13269

@bluwy
Copy link
Member

bluwy commented Jun 26, 2023

We could probably do a special node17 check for this, but not sure if it's worth handling it given it has EOL.

@patak-dev
Copy link
Member

I think if node 17 is important enough for someone we could accept a patch to support it until Vite 5. Not being able to load the config file in 17 right now feels too big a price to pay for what we gained by removing the temporal file.

@brillout
Copy link
Contributor Author

Sounds good to me (I like the approach "let's see if someone need this"). Although I'd show "Vite doesn't work with Node.js 17. Please update your Node.js version or reach out if you need Node.js 17 support." instead of this error.

@eolme
Copy link

eolme commented Jun 26, 2023

It is somehow reproduced on node 18 and 20 too on MacBook M1 MacOS 12, but on vite 4.3.x everything is fine

@chinbor
Copy link

chinbor commented Jun 27, 2023

I guess this is related to nodejs/node#42860. The fixes was released in Node.js 16.17.0 and Node.js 18.1.0. But Node.js 17.x didn't have a fix because Node.js 17 EOL-ed in 2022-06 (The issue was reported in 2022-08).

We should have dropped Node.js 17 in Vite 3 (2022-07) or Vite 4. https://vitejs.dev/blog/announcing-vite3.html#compatibility-notes

Or maybe we can already say we don't support Node.js 17 as we setup the release page. https://vitejs.dev/releases.html#node-js-non-lts-versions

refs #13269

It works!!

@brillout
Copy link
Contributor Author

@patak-dev Vite-plugin-ssr's CI doesn't use Node.js 17 anymore; it should be green again.

@bluwy
Copy link
Member

bluwy commented Jun 28, 2023

Actually given we have support for node 16 and above, and the node fix is only applied to node 16.17 and 18.1, it would be better to support a fallback by default. We also used to be stricter when it comes to supported minors.

Just need to make sure in Vite 5 we support 18.1 and above so we can remove the fallback.

@sapphi-red
Copy link
Member

Closing as we reverted #13269

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants