Replies: 3 comments 2 replies
-
check for typos in imports (or if you're importing the same thing from different specifiers ({X} from "pkg/X" and also "{X} from pkg" |
Beta Was this translation helpful? Give feedback.
-
hola pudiste solucionarlo? me esta pasando lo mismo y ya nose como resolverlo... |
Beta Was this translation helpful? Give feedback.
-
I was using @frejun/softphone-web-sdk in a shared hook across multiple apps in a monorepo. Even though the import was correct, Vite threw an error when running all apps together because it tried to pre-bundle the same dependency separately for each app, leading to a conflict. To solve this, I added the library to optimizeDeps.exclude in vite.config.ts: This tells Vite not to pre-bundle the library, which prevents the conflict. Everything works fine now for me. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
vite.config.ts
import { defineConfig } from 'vite'
import { resolve } from 'path'
import vue from '@vitejs/plugin-vue'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue(),
],
resolve: {
alias: {
"@": resolve(__dirname, "src")
},
},
server: {
proxy: {
'/api': {
target: 'http://43.138.109.120:3000',
changeOrigin: true,
rewrite: (path) => path.replace(/^/api/, '')
}
}
}
})
ts.config.ts:
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ES2020", "DOM", "DOM.Iterable"],
"skipLibCheck": true,
"baseUrl": ".",
"paths": {
"@/": ["src/"]
},
/* Bundler mode /
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "preserve",
/ Linting /
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src/**/.ts", "src//*.d.ts", "src//.tsx", "src/**/.vue"],
"references": [{ "path": "./tsconfig.node.json" }]
}
package.json:
{
"name": "my-blog",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite --open",
"build": "vue-tsc && vite build",
"preview": "vite preview"
},
"dependencies": {
"axios": "^1.5.1",
"element-plus": "^2.4.0",
"vue": "^3.3.4",
"vue-router": "^4.2.5"
},
"devDependencies": {
"@types/node": "^20.8.6",
"@vitejs/plugin-vue": "^4.2.3",
"fast-glob": "^3.3.1",
"typescript": "^5.0.2",
"vite": "^4.4.5",
"vite-plugin-svg-icons": "^2.0.1",
"vue-tsc": "^1.8.5"
}
}
Code in all other files like App.vue,main.ts has been commented.This problem I agonized for a long time, opened how many pages, debugging and debugging, the computer is burning up!
Beta Was this translation helpful? Give feedback.
All reactions