vite icon indicating copy to clipboard operation
vite copied to clipboard

"Rollup failed to resolve import" on Windows

Open yanglee2421 opened this issue 6 months ago • 1 comments

Describe the bug

Everything works fine in development mode but when executing build command I get the following error

vite v7.0.0 building for production...
✓ 588 modules transformed.
✗ Build failed in 8.53s
error during build:
[vite]: Rollup failed to resolve import "prop-types" from "C:/Users/yangl/Documents/workspace/yanglee2421.github.io/node_modules/.pnpm/@[email protected]_@emotio_9e006404fc3586f7b9058af5f597a2e0/node_modules/@mui/material/esm/Card/Card.js".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
    at viteLog (file:///C:/Users/yangl/Documents/workspace/yanglee2421.github.io/node_modules/.pnpm/[email protected]_@[email protected]_331d272363cbca6bf42d8fecdff3ce7a/node_modules/vite/dist/node/chunks/dep-Bsx9IwL8.js:34193:57)
    at file:///C:/Users/yangl/Documents/workspace/yanglee2421.github.io/node_modules/.pnpm/[email protected]_@[email protected]_331d272363cbca6bf42d8fecdff3ce7a/node_modules/vite/dist/node/chunks/dep-Bsx9IwL8.js:34231:73
    at onwarn (file:///C:/Users/yangl/Documents/workspace/yanglee2421.github.io/node_modules/.pnpm/@[email protected]__10cc47ad24867011aa08e24c53755116/node_modules/@vitejs/plugin-react/dist/index.mjs:104:9)
    at file:///C:/Users/yangl/Documents/workspace/yanglee2421.github.io/node_modules/.pnpm/[email protected]_@[email protected]_331d272363cbca6bf42d8fecdff3ce7a/node_modules/vite/dist/node/chunks/dep-Bsx9IwL8.js:34231:28
    at onRollupLog (file:///C:/Users/yangl/Documents/workspace/yanglee2421.github.io/node_modules/.pnpm/[email protected]_@[email protected]_331d272363cbca6bf42d8fecdff3ce7a/node_modules/vite/dist/node/chunks/dep-Bsx9IwL8.js:34226:3)
    at onLog (file:///C:/Users/yangl/Documents/workspace/yanglee2421.github.io/node_modules/.pnpm/[email protected]_@[email protected]_331d272363cbca6bf42d8fecdff3ce7a/node_modules/vite/dist/node/chunks/dep-Bsx9IwL8.js:34014:4)
    at file:///C:/Users/yangl/Documents/workspace/yanglee2421.github.io/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:20799:32
    at Object.logger [as onLog] (file:///C:/Users/yangl/Documents/workspace/yanglee2421.github.io/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:22679:9)
    at ModuleLoader.handleInvalidResolvedId (file:///C:/Users/yangl/Documents/workspace/yanglee2421.github.io/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:21425:26)
    at file:///C:/Users/yangl/Documents/workspace/yanglee2421.github.io/node_modules/.pnpm/[email protected]/node_modules/rollup/dist/es/shared/node-entry.js:21383:26
 ELIFECYCLE  Command failed with exit code 1.

This problem seems to only occur on Windows platforms. It does not occur when I execute pnpm build in github actions (ubuntu-latest)

Reproduction

https://github.com/yanglee2421/yanglee2421.github.io

Steps to reproduce

  1. On Windows
  2. pnpm i
  3. pnpm build

System Info

System:
    OS: Windows 11 10.0.26100
    CPU: (12) x64 AMD Ryzen 5 7640HS w/ Radeon 760M Graphics     
    Memory: 4.01 GB / 15.18 GB
  Binaries:
    Node: 22.17.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.9.2 - C:\Program Files\nodejs\npm.CMD
    pnpm: 10.12.3 - C:\Program Files\nodejs\pnpm.CMD
  Browsers:
    Edge: Chromium (132.0.2957.115)
  npmPackages:
    @vitejs/plugin-react: ^4.6.0 => 4.6.0 
    vite: ^7.0.0 => 7.0.0

Used Package Manager

pnpm

Logs

No response

Validations

yanglee2421 avatar Jun 25 '25 12:06 yanglee2421

When repalce vite with rolldown-vite, this problem is solved

yanglee2421 avatar Jun 25 '25 12:06 yanglee2421

It seems to be caused by https://github.com/rollup/rollup/issues/5989. It is fixed in rollup v4.44.1.

sapphi-red avatar Jun 26 '25 04:06 sapphi-red