RollupError:无法解决 - Vercel React vite 部署

问题描述 投票:0回答:2

我尝试在 vercel 或 netlify 上部署我的 React vite 项目,但出现错误:

RollupError: Could not resolve "./reviews/Reviews" from "src/components/Pages/CarDetails/CarDetails.jsx"
    at error (file:///vercel/path0/node_modules/rollup/dist/es/shared/node-entry.js:2128:30)
    at ModuleLoader.handleInvalidResolvedId (file:///vercel/path0/node_modules/rollup/dist/es/shared/node-entry.js:23782:24)
    at file:///vercel/path0/node_modules/rollup/dist/es/shared/node-entry.js:23744:26
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Error: Command "yarn run build" exited with 1
Deployment completed
BUILD_UTILS_SPAWN_1: Command "yarn run build" exited with 1

这里是我的 vite.config.js:

import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

// https://vitejs.dev/config/
export default defineConfig({
    plugins: [react()],
    vite: {
        server: {
            watch: {
                usePolling: true,
            },
        },
    },
});

google了一下,还是没有答案

reactjs vite vercel netlify
2个回答
0
投票

我遇到了同样的问题,它与当 tsconfig.jsoncompile_options 配置为以下内容时从 .tsx 导入 .jsx 文件有关:


"paths": {
  "*": ["*", "*.tsx"]
}

您可以将此配置更改为您希望在编译时自动检测到的内容。


0
投票

我遇到了同样的问题,这表示“src/components/Pages/CarDetails/CarDetails.jsx”正在尝试导入“./reviews/Reviews”文件,但找不到它。

只需转到“CarDetails.jsx”组件并检查“./reviews/Reviews”大小写(大写和小写)的导入语句是否正确。如果不正确则修复它。因为这些东西可能在你的本地机器上工作得很好,但在 vercel 中却出现了问题。

© www.soinside.com 2019 - 2024. All rights reserved.