Error: Dynamic require of "path" is not supported

See original GitHub issue

Hi, great work on this!

After updating from 0.8.7 to 0.9.1 i get the following error when building:

failed to load config from vite.config.js
error when starting dev server:
Error: Dynamic require of "path" is not supported
    at file:///src/webapp/node_modules/.pnpm/vite-aliases@0.9.1_sass@1.49.9/node_modules/vite-aliases/dist/index.mjs:30:9
    at node_modules/fast-glob/out/utils/path.js (file:///src/webapp/node_modules/.pnpm/vite-aliases@0.9.1_sass@1.49.9/node_modules/vite-aliases/dist/index.mjs:131:16)
    at __require2 (file:///src/webapp/node_modules/.pnpm/vite-aliases@0.9.1_sass@1.49.9/node_modules/vite-aliases/dist/index.mjs:36:50)
    at node_modules/fast-glob/out/utils/index.js (file:///src/webapp/node_modules/.pnpm/vite-aliases@0.9.1_sass@1.49.9/node_modules/vite-aliases/dist/index.mjs:3235:16)
    at __require2 (file:///src/webapp/node_modules/.pnpm/vite-aliases@0.9.1_sass@1.49.9/node_modules/vite-aliases/dist/index.mjs:36:50)
    at node_modules/fast-glob/out/managers/tasks.js (file:///src/webapp/node_modules/.pnpm/vite-aliases@0.9.1_sass@1.49.9/node_modules/vite-aliases/dist/index.mjs:3253:17)
    at __require2 (file:///src/webapp/node_modules/.pnpm/vite-aliases@0.9.1_sass@1.49.9/node_modules/vite-aliases/dist/index.mjs:36:50)
    at node_modules/fast-glob/out/index.js (file:///src/webapp/node_modules/.pnpm/vite-aliases@0.9.1_sass@1.49.9/node_modules/vite-aliases/dist/index.mjs:5167:23)
    at __require2 (file:///src/webapp/node_modules/.pnpm/vite-aliases@0.9.1_sass@1.49.9/node_modules/vite-aliases/dist/index.mjs:36:50)
    at file:///src/webapp/node_modules/.pnpm/vite-aliases@0.9.1_sass@1.49.9/node_modules/vite-aliases/dist/index.mjs:5240:32
 ELIFECYCLE  Command failed with exit code 1.

working: working.zip repro: repro.zip

using versions vite: 2.8.6 node: v17.1.0 pnpm: 6.23.2 npm: 8.1.2

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:20 (11 by maintainers)

github_iconTop GitHub Comments

7reactions
extremelygooddevelopercommented, Mar 10, 2022

After further troubleshooting i managed to build with 0.9.1 by removing type: "module" from package.json. Would it be worth looking into why type: "module" worked with 0.8.7 but not with 0.9.1?.

new-repro.zip

3reactions
MattMarquisecommented, Oct 19, 2022

@Subwaytime I had this same issue recently with new Vite project and removing “type”: “module” fixed the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vitejs | Uncaught Error: Dynamic require of "<path>.svg" is not ...
I don't know if it will for react-flagpack; this is likely a require statement that is breaking the build... I found a solution...
Read more >
dynamic require of "path" is not supported - GitHub - You.com
Describe the bug Im trying to use this awesome looking lib with esbuild targeting cloudflare workers and I am getting the following error:...
Read more >
Netlify Serverless Typescript functions fail with dynamic requires
Typescript serverless functions seem to be failing for me with {"errorType":"Error","errorMessage":"Dynamic require of \"util\" is not supported" ...
Read more >
vite-plugin-dynamic-import - npm
vite-plugin-dynamic-import. TypeScript icon, indicating that this package has built-in type declarations. 1.2.4 • Public • Published a month ...
Read more >
Features | Vite
Native ES imports do not support bare module imports like the following: js import { someMethod } from 'my-dep'. The above will throw...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found