【发布时间】:2022-06-24 04:34:15
【问题描述】:
遇到错误
[vite] 内部服务器错误:无法读取未定义的属性“长度”
这是在尝试使用 vite 运行我的 vue 项目时发生的。
下面是错误堆栈:
构建失败,出现 1 个错误:node_modules/vite/dist/node/chunks/dep-27bc1ab8.js:59574:34:错误:[插件:vite:dep-scan] 无法读取未定义 2 的属性“长度”:下午 44:29 [vite] 内部服务器错误:无法读取匹配时未定义的属性“长度”(/Users/pandocorp/Desktop/pando/codes/pando-app/frontend/shipper/node_modules/vite/dist/node/chunks /dep-27bc1ab8.js:59574:35) 在 /Users/pandocorp/Desktop/pando/codes/pando-app/frontend/shipper/node_modules/vite/dist/node/chunks/dep-27bc1ab8.js:59633:58在 Context.resolveId 的 Array.find () (/Users/pandocorp/Desktop/pando/codes/pando-app/frontend/shipper/node_modules/vite/dist/node/chunks/dep-27bc1ab8.js:59633:42)在 Object.resolveId (/Users/pandocorp/Desktop/pando/codes/pando-app/frontend/shipper/node_modules/vite/dist/node/chunks/dep-27bc1ab8.js:36609:55) 在 processTicksAndRejections (internal/process /task_queues.js:95:5) 在异步 ModuleGraph.resolveUrl (/Users/pandocorp/Desktop/pando/codes/pando-app/frontend/shipper/node_modules /vite/dist/node/chunks/dep-27bc1ab8.js:56244:26) 在异步 ModuleGraph.getModuleByUrl (/Users/pandocorp/Desktop/pando/codes/pando-app/frontend/shipper/node_modules/vite/dist/ node/chunks/dep-27bc1ab8.js:56124:23) 在异步 doTransform (/Users/pandocorp/Desktop/pando/codes/pando-app/frontend/shipper/node_modules/vite/dist/node/chunks/dep-27bc1ab8 .js:55582:20)
我的 vite.config.js
import { defineConfig } from 'vite';
import { createVuePlugin } from 'vite-plugin-vue2';
const config = require('./config');
const path = require('path');
export default defineConfig({
plugins: [createVuePlugin()],
server: {
port: 8080,
},
resolve: {
alias: [
{
'@': path.resolve(__dirname, './src'),
},
{
'@common': path.resolve(__dirname, '../common-v2'),
},
// {
// find: path.resolve(__dirname, '../static'),
// replacement: config.dev.assetsSubDirectory,
// ignore: ['.'],
// },
// {
// find: path.resolve(__dirname, '../firebase-messaging-sw.js'),
// replacement: 'firebase-messaging-sw.js',
// ignore: ['.'],
// },
],
},
build: {
chunkSizeWarningLimit: 600,
cssCodeSplit: false,
},
});
【问题讨论】:
-
你能分享一下repo源链接吗?