Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Internal server error: Failed to resolve import "' + name + '" from "node_modules/.vite/react-app-polyfill_stable.js?v=9b889127". Does the file exist? #7429

Closed
7 tasks done
SivanWong opened this issue Mar 24, 2022 · 2 comments

Comments

@SivanWong
Copy link

Describe the bug

在使用vite启动项目时,遇到一个问题:
image

在此之前,有添加插件@originjs/vite-plugin-commonjs,详情可以参考另一个issue:#5308

有看到另一个类似的问题,但也没有解决方案,求大佬们指教

Reproduction

无法重现

System Info

System:
    OS: macOS 10.15.7
    CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 195.29 MB / 16.00 GB
    Shell: 5.7.1 - /bin/zsh
  Binaries:
    Node: 12.22.3 - /usr/local/opt/node@12/bin/node
    Yarn: 1.22.4 - /usr/local/bin/yarn
    npm: 6.14.13 - /usr/local/opt/node@12/bin/npm
  Browsers:
    Chrome: 99.0.4844.83
    Firefox: 89.0.2
    Safari: 15.3
  npmPackages:
    @vitejs/plugin-legacy: ^1.7.1 => 1.7.1 
    @vitejs/plugin-react: ^1.2.0 => 1.2.0 
    @vitejs/plugin-react-refresh: ^1.3.6 => 1.3.6 
    vite: ^2.8.6 => 2.8.6

Used Package Manager

npm

Logs

[vite] server restarted.
[vite] Internal server error: Failed to resolve import "' + name + '" from "node_modules/.vite/react-app-polyfill_stable.js?v=9b889127". Does the file exist?
  Plugin: vite:import-analysis
  File: /node_modules/.vite/react-app-polyfill_stable.js?v=9b889127
  1  |  import * as __require_for_vite_gtQ0ed from "' + name + '";
     |                                              ^
  2  |  import {
  3  |    require_runtime
      at formatError (/node_modules/vite/dist/node/chunks/dep-9c153816.js:38098:46)
      at TransformContext.error (/node_modules/vite/dist/node/chunks/dep-9c153816.js:38094:19)
      at normalizeUrl (/node_modules/vite/dist/node/chunks/dep-9c153816.js:69819:26)
      at async TransformContext.transform (/node_modules/vite/dist/node/chunks/dep-9c153816.js:69959:57)
      at async Object.transform (/node_modules/vite/dist/node/chunks/dep-9c153816.js:38334:30)
      at async doTransform (/node_modules/vite/dist/node/chunks/dep-9c153816.js:53030:29)

Validations

@patak-dev
Copy link
Member

patak-dev commented Mar 24, 2022

This isn't valid import "' + name + '", you can use a dynamic import. Vite uses https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars internally to support variables in dynamic imports.

@SivanWong
Copy link
Author

This isn't valid import "' + name + '", you can use a dynamic import. Vite uses https://github.com/rollup/plugins/tree/master/packages/dynamic-import-vars internally to support variables in dynamic imports.

但这是node_modules里的dynamic import,那要怎么处理

@vitejs vitejs locked and limited conversation to collaborators Mar 24, 2022
@patak-dev patak-dev converted this issue into discussion #7433 Mar 24, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Projects
None yet
Development

No branches or pull requests

2 participants