Problem
I am using Vite for some front end development, and when I used an external library which is using the "path" library, it throws this error:
Module "path" has been externalized for browser compatibility and cannot be accessed in client code.
Solution
Steps:
- Install "path-browserify":
$ npm install path-browserify
- Add code to
vite.config.ts
:
import path from "path-browserify" export default defineConfig({ plugins: [vue()], resolve: { alias: { path: "path-browserify", }, }, })
Top comments (3)
How about when we want to use
node:path
in ourvite.config.ts
? I am trying to use it but to no avail.Thank you!
Thanks for sharing Shishir Raven