-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
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
[V3] Error on build in CI: Cannot find module 'node:path' in vite.config.ts #9113
Comments
For example you can see the following example in the docs about building in library mode:
Which means using |
Also worth noting, I've just managed to fix my build by updating my CI to use node 18 instead of node 15. (]Relevant PR](https://github.com/liana-p/narrat/pull/44)) I don't know if vite recommends a specific node version (couldn't find any in the docs), but before vite 3 my build worked fine on node 15 in CI, so I suppose something changed |
Vite uses |
Right but this has to be a change in v3 that wasn't in v2 right? Because my vite config worked fine until now, it's specifically updating to v3 that broke my CI. So all I'm saying is that this can be an unexpected a breaking change for anyone else who was doing something similar and running an older version of node |
Yes, this is a change introduced in v3. This was forgotten to mention in docs/migration guide. This is a intended breaking change because node 15 is already EOL. |
I have the same issue with node v14.17.5, everything works after update node to v18.6.0 :) |
Describe the bug
As Vite v3 is released, I've updated my project to use it. However, I am getting a new error when building in CI (GitHub workflows).
The error is
Error: Cannot find module 'node:path'
which seems to mean that the build isn't running in a node environment. However this script used to run fine on CI without any changes. Updating to Vite 3 made it break.My
vite.config.ts
file uses node'spath.resolve
which I found advised somewhere in docs in regards to using the lib mode I think. It was a while ago. Relevant bit of the config:It seems using node's
path
module breaks, whereas it didn't before updating to v3.In the reproduction link, I put a link to the GitHub workflow that failed.
Reproduction
https://github.com/liana-p/narrat/runs/7337553246?check_suite_focus=true
System Info
Used Package Manager
npm
Logs
Run npm run build --if-present
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:924:15)
at Function.Module._load (node:internal/modules/cjs/loader:769:27)
at Module.require (node:internal/modules/cjs/loader:996:19)
at require (node:internal/modules/cjs/helpers:92:18)
at Object. (/home/runner/work/narrat/narrat/node_modules/vite/dist/node-cjs/publicUtils.cjs:5:14)
at Module._compile (node:internal/modules/cjs/loader:1092:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1121:10)
at Object._require.extensions..js (file:///home/runner/work/narrat/narrat/node_modules/vite/dist/node/chunks/dep-561c5231.js:62742:13)
at Module.load (node:internal/modules/cjs/loader:972:32)
at Function.Module._load (node:internal/modules/cjs/loader:813:14)
Error: Process completed with exit code 1.
Validations
The text was updated successfully, but these errors were encountered: