Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[vite:dep-pre-bundle] Failed to resolve entry for package "@ant-design/colors". The package may have incorrect main/module/exports specified in its package.json. #2883

Closed
6 tasks
Shu-Ji opened this issue Apr 6, 2021 · 4 comments

Comments

@Shu-Ji
Copy link

Shu-Ji commented Apr 6, 2021

Describe the bug

不能启动 vite 开发模式,报错如下。

我使用的是 pnpm,切换到 yarn 就不报错了。

我检查过这几个报错的库,里面的main/module/exports 指向是正确的,唯一不同的是,这些库我不直接使用,而是我使用 antd 的时候,antd 依赖了这些库。

会是因为 pnpm 的目录链接关系?导致 vite 找不到正确的路径从而报错吗? 我不知道这是 pnpm 的问题,还是说 vite 需要特殊操作来兼容 pnpm 的 node_modules 目录结构?因为这些被依赖的库被安装在了.pnpm 目录下,再链接 到相应地方的,而不是直接在 node_modules 目录下。

当前我只能将 pnpm 切换 到 yarn,临时救急。

Reproduction

System Info

Output of npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers:

System:
    OS: macOS 11.2.3
    CPU: (4) x64 Intel(R) Core(TM) i5-7360U CPU @ 2.30GHz
    Memory: 21.48 MB / 8.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 15.13.0 
    Yarn: 1.22.10
    npm: 7.7.6 
  Browsers:
    Chrome: 89.0.4389.114
    Safari: 14.0.3
  npmPackages:
    vite: ^2.1.5 => 2.1.5

Used package manager: pnpm

Logs

Error: Build failed with 3 errors:
node_modules/.pnpm/vite@2.1.5/node_modules/vite/dist/node/chunks/dep-66eb515d.js:32070:14: error: [vite:dep-pre-bundle] Failed to resolve entry for package "@ant-design/colors". The package may have incorrect main/module/exports specified in its package.json.
node_modules/.pnpm/vite@2.1.5/node_modules/vite/dist/node/chunks/dep-66eb515d.js:32070:14: error: [vite:dep-pre-bundle] Failed to resolve entry for package "@ant-design/colors". The package may have incorrect main/module/exports specified in its package.json.
node_modules/.pnpm/vite@2.1.5/node_modules/vite/dist/node/chunks/dep-66eb515d.js:32070:14: error: [vite:dep-pre-bundle] Failed to resolve entry for package "@ant-design/react-slick". The package may have incorrect main/module/exports specified in its package.json.

Before submitting the issue, please make sure you do the following

  • Read the Contributing Guidelines.
  • Read the docs.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Provide a description in this issue that describes the bug.
  • Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
  • Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
@fulus06
Copy link

fulus06 commented Apr 6, 2021

我也是使用pnpm遇到了这个问题

@fulus06
Copy link

fulus06 commented Apr 6, 2021

我使用pnpm5没问题,使用pnpm6会出现这个错误

@sodatea
Copy link
Member

sodatea commented Apr 10, 2021

升到 pnpm 6.0.1 试试?
可能是因为目录中的 # 引起的,已经在 6.0.1 里改掉了 https://github.com/pnpm/pnpm/releases/tag/v6.0.1

@Shu-Ji
Copy link
Author

Shu-Ji commented Apr 12, 2021

@sodatea 已经好了,我把这个关了

@Shu-Ji Shu-Ji closed this as completed Apr 12, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jul 16, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants