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

fix: Vite 5 - The CJS build of Vite's Node API is deprecated #62

Merged
merged 1 commit into from
Feb 11, 2024

Conversation

renataogarcia
Copy link
Contributor

The CJS build of Vite's Node API is deprecated.

Trace: The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.
    at warnCjsUsage (<path>/node_modules/vite/index.cjs:32:3)
    at Object.<anonymous> (<path>/node_modules/vite/index.cjs:3:1)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (<path>/node_modules/vite-plugin-virtual-mpa/dist/index.js:89:19)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)

@emosheeep
Copy link
Owner

I just removed these line in v1.10.0, does that cause some problems? How did you get this warn?

@renataogarcia
Copy link
Contributor Author

I got it with version 1.10.0 and vite 5.1.1

Running:

VITE_CJS_TRACE=true npx vite dev

@emosheeep
Copy link
Owner

Looks like a little confusing....I tried to add the lines but the warn is not gone, util I change the viteconfig to mts or add "type": "module" to my project. sorry i missed this before.

I guess vite transforms the config file into cjs format and load it using require, and the module filed is used by bundle tool, but not support by node.

@renataogarcia
Copy link
Contributor Author

Looks like a little confusing....I tried to add the lines but the warn is not gone, util I change the viteconfig to mts or add "type": "module" to my project. sorry i missed this before.

I guess vite transforms the config file into cjs format and load it using require, and the module filed is used by bundle tool, but not support by node.

Yeah, indeed... I have "type":"module": set.

@emosheeep emosheeep merged commit 9d5e13e into emosheeep:master Feb 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants