Skip to content

Fail to load packages installed from Git repo with pnpm v9 #17459

@kong-dev

Description

@kong-dev

Describe the bug

Since upgrading to pnpm v9, Vite has failed to load packages installed from Git repo.

Error like this
  vite:load 5.98ms [fs] /main.js +0ms
  vite:resolve 6.61ms uuid-mirror -> /Users/kongdev/Workspace/demo/vite-issue/node_modules/.pnpm/uuid@git+https+++gitee.com+kongdev+uuid.git#da189d1792993d0da4b5008ea98c5ef48896739c/node_modules/uuid/dist/esm-browser/index.js +29ms
  vite:import-analysis 15.07ms [1 imports rewritten] main.js +0ms
  vite:transform 24.05ms /main.js +0ms
3:06:02 PM [vite] Pre-transform error: Failed to load url /node_modules/.pnpm/uuid@git+https+++gitee.com+kongdev+uuid.git?import#da189d1792993d0da4b5008ea98c5ef48896739c/node_modules/uuid/dist/esm-browser/index.js (resolved id: /Users//kongdev/Workspace/demo/vite-issue/node_modules/.pnpm/uuid@git+https+++gitee.com+kongdev+uuid.git#da189d1792993d0da4b5008ea98c5ef48896739c/node_modules/uuid/dist/esm-browser/index.js) in /Users//kongdev/Workspace/demo/vite-issue/main.js. Does the file exist?

Repos on Github or Gitlab exhibit no issues, yet those on self-hosted services or other Git providers encounter problems.

It seems there is # in the file path that may be causing the issue. logic here

Reproduction

https://github.com/kong-dev/vite-issue

Steps to reproduce

The repository above is a minimal reproduction including 2 dependencies:

  • 'uuid' from the npm registry
  • 'uuid-mirror' from the mirrored Git repo

Steps:

  • Install pnpm v9
  • Clone the repo above
  • Run pnpm install
  • Start the dev server by running pnpm run dev
  • Access in the browser

System Info

System:
    OS: macOS 14.5
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 418.56 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.14.0 - ~/.nvm/versions/node/v20.14.0/bin/node
    Yarn: 1.22.17 - /usr/local/bin/yarn
    npm: 10.7.0 - ~/.nvm/versions/node/v20.14.0/bin/npm
    pnpm: 9.3.0 - /usr/local/bin/pnpm
  Browsers:
    Chrome: 126.0.6478.57
    Safari: 17.5
  npmPackages:
    vite: ^5.2.13 => 5.2.13

Used Package Manager

pnpm

Logs

No response

Validations

Metadata

Metadata

Assignees

No one assigned

    Labels

    p4-importantViolate documented behavior or significantly improves performance (priority)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions