I migrated from webpack to vite successfully in a vue2 project and now I am upgrading from vue2 to vue3.
I made it until step 4 in this guide: https://v3-migration.vuejs.org/migration-build.html#installation, and now the build process gives me this error.
ERROR: [plugin: vite:dep-scan] Cannot read properties of undefined (reading 'length')
It looks like the vite compat builder is not able to find the file /src/main.js
, because if I rename or even delete the file, the error remains the same.
Did I miss something?
✘ [ERROR] [plugin vite:dep-scan] Cannot read properties of undefined (reading 'length')
node_modules/vite/dist/node/chunks/dep-59dc6e00.js:60384:34:
60384 │ if (importee.length < pattern.length) {
╵ ^
at matches (/home/user/projects/ipfs-search/dweb-search-frontend/node_modules/vite/dist/node/chunks/dep-59dc6e00.js:60384:35)
at /home/user/projects/ipfs-search/dweb-search-frontend/node_modules/vite/dist/node/chunks/dep-59dc6e00.js:60443:58
at Array.find (<anonymous>)
at Context.resolveId (/home/user/projects/ipfs-search/dweb-search-frontend/node_modules/vite/dist/node/chunks/dep-59dc6e00.js:60443:42)
at Object.resolveId (/home/user/projects/ipfs-search/dweb-search-frontend/node_modules/vite/dist/node/chunks/dep-59dc6e00.js:38837:55)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async resolve (/home/user/projects/ipfs-search/dweb-search-frontend/node_modules/vite/dist/node/chunks/dep-59dc6e00.js:39049:26)
at async /home/user/projects/ipfs-search/dweb-search-frontend/node_modules/vite/dist/node/chunks/dep-59dc6e00.js:39257:34
at async callback (/home/user/projects/ipfs-search/dweb-search-frontend/node_modules/esbuild/lib/main.js:929:28)
at async handleRequest (/home/user/projects/ipfs-search/dweb-search-frontend/node_modules/esbuild/lib/main.js:709:30)
This error came from the "onResolve" callback registered here:
node_modules/vite/dist/node/chunks/dep-59dc6e00.js:39253:18:
39253 │ build.onResolve({
╵ ~~~~~~~~~
at setup (/home/user/projects/ipfs-search/dweb-search-frontend/node_modules/vite/dist/node/chunks/dep-59dc6e00.js:39253:19)
at handlePlugins (/home/user/projects/ipfs-search/dweb-search-frontend/node_modules/esbuild/lib/main.js:851:23)
at Object.buildOrServe (/home/user/projects/ipfs-search/dweb-search-frontend/node_modules/esbuild/lib/main.js:1145:7)
at /home/user/projects/ipfs-search/dweb-search-frontend/node_modules/esbuild/lib/main.js:2087:17
at new Promise (<anonymous>)
at Object.build (/home/user/projects/ipfs-search/dweb-search-frontend/node_modules/esbuild/lib/main.js:2086:14)
at Object.build (/home/user/projects/ipfs-search/dweb-search-frontend/node_modules/esbuild/lib/main.js:1935:51)
at /home/user/projects/ipfs-search/dweb-search-frontend/node_modules/vite/dist/node/chunks/dep-59dc6e00.js:38997:54
at Array.map (<anonymous>)
The plugin "vite:dep-scan" was triggered by this import
html:/home/user/projects/ipfs-search/dweb-search-frontend/index.html:1:7:
1 │ import "/src/main.js"
╵ ~~~~~~~~~~~~~~
Build failed with 1 error:
node_modules/vite/dist/node/chunks/dep-59dc6e00.js:60384:34: ERROR: [plugin: vite:dep-scan] Cannot read properties of undefined (reading 'length')
vite.config.js:
import { defineConfig } from 'vite';
import path from 'path';
import createVuePlugin from '@vitejs/plugin-vue';
export default defineConfig({
plugins: [
createVuePlugin({
template: {
compilerOptions: {
compatConfig: {
MODE: 2,
},
},
},
}),
],
server: {
port: 8080,
},
resolve: {
alias: [
{
vue: '@vue/compat',
},
{
find: '@',
replacement: path.resolve(__dirname, 'src'),
},
],
},
});