【问题标题】:Internal server error: Cannot read property 'length' of undefined内部服务器错误:无法读取未定义的属性“长度”
【发布时间】: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源链接吗?

标签: vue.js vite


【解决方案1】:

Na raiz do projeto precisa ter a pasta tailwind.config.js, se não tiver essa pasta terá esse erro。

Caso não tenha essa 意大利面 instale com o comando $ npx tailwindcss init -p Depois rode o projeto com o comando npm run dev

Foi o que fiz e aqui deu certo。

态度,

【讨论】:

    猜你喜欢
    • 2022-11-12
    • 2019-01-18
    • 2015-05-08
    • 2020-06-02
    • 1970-01-01
    • 2021-11-04
    • 2015-02-05
    • 2017-11-25
    • 2021-02-26
    相关资源
    最近更新 更多