Skip to content

"Rollup failed to resolve import" on Windows #20293

Closed
@yanglee2421

Description

@yanglee2421

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/@mui+material@7.1.2_@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/vite@7.0.0_@types+node@24.0_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/vite@7.0.0_@types+node@24.0_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/@vitejs+plugin-react@4.6.0__10cc47ad24867011aa08e24c53755116/node_modules/@vitejs/plugin-react/dist/index.mjs:104:9)
    at file:///C:/Users/yangl/Documents/workspace/yanglee2421.github.io/node_modules/.pnpm/vite@7.0.0_@types+node@24.0_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/vite@7.0.0_@types+node@24.0_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/vite@7.0.0_@types+node@24.0_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/rollup@4.44.0/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/rollup@4.44.0/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/rollup@4.44.0/node_modules/rollup/dist/es/shared/node-entry.js:21425:26)
    at file:///C:/Users/yangl/Documents/workspace/yanglee2421.github.io/node_modules/.pnpm/rollup@4.44.0/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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug: upstreamBug in a dependency of Vitep3-minor-bugAn edge case that only affects very specific usage (priority)

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions