Internal server error when importing package
See original GitHub issue- [X ] Read the docs.
- [X ] Use Vite >=2.0. (1.x is no longer supported)
- [X ] If the issue is related to 1.x -> 2.0 upgrade, read the Migration Guide first.
Describe the bug
Cant import module from highcharts, receive following error:
[vite] Internal server error: Deep import "highcharts/modules/stock" should be avoided because dependency "highcharts" has been pre-optimized. Prefer importing directly from the module entry:
I tried to fix adding to optmizeDeps but didnt worked as I expected.
// vite.config.js optimizeDeps: { include: ['highcharts', 'highcharts/modules/stock'], exclude: [] },
Reproduction: https://github.com/leonardoks16/vite-highcharts3
System Info
vite
version: 2.0.0-beta.12- Operating System: Windows 10
- Node version: v14.15.1
- Package manager: npm@6.14.8
Logs
`vite:config bundled config file loaded in 245ms +0ms vite:config using resolved config: { vite:config optimizeDeps: { vite:config include: [ ‘highcharts’, ‘highcharts/modules/stock’ ], vite:config exclude: [] vite:config }, vite:config plugins: [ vite:config ‘alias’, vite:config ‘vite:dynamic-import-polyfill’, vite:config ‘vite:resolve’, vite:config ‘vite:html’, vite:config ‘vite:css’, vite:config ‘vite:esbuild’, vite:config ‘vite:json’, vite:config ‘vite:wasm’, vite:config ‘vite:worker’, vite:config ‘vite:asset’, vite:config ‘vite:vue’, vite:config ‘vite:css-post’, vite:config ‘vite:client-inject’, vite:config ‘vite:import-analysis’ vite:config ], vite:config server: {}, vite:config define: { VUE_OPTIONS_API: true, VUE_PROD_DEVTOOLS: false }, vite:config configFile: ‘/Users/nexxus/Desktop/sdsds/my-vite/vite.config.js’, vite:config inlineConfig: { vite:config root: undefined, vite:config mode: undefined, vite:config configFile: undefined, vite:config logLevel: undefined, vite:config server: {} vite:config }, vite:config root: ‘/Users/nexxus/Desktop/sdsds/my-vite’, vite:config command: ‘serve’, vite:config mode: ‘development’, vite:config isProduction: false, vite:config optimizeCacheDir: ‘\Users\nexxus\Desktop\sdsds\my-vite\node_modules\.vite’, vite:config alias: [ vite:config { vite:config find: /^/@vite//, vite:config replacement: ‘C:\XXXXX\XXXX\XXXX\XXXX\my-vite\node_modules\vite\dist\client/’ vite:config } vite:config ], vite:config build: { vite:config base: ‘/’, vite:config target: [ ‘es2019’, ‘edge16’, ‘firefox60’, ‘chrome61’, ‘safari11’ ], vite:config polyfillDynamicImport: true, vite:config outDir: ‘dist’, vite:config assetsDir: ‘assets’, vite:config assetsInlineLimit: 4096, vite:config cssCodeSplit: true, vite:config sourcemap: false, vite:config rollupOptions: {}, vite:config commonjsOptions: { include: [Array], extensions: [Array] }, vite:config minify: ‘terser’, vite:config terserOptions: {}, vite:config cleanCssOptions: {}, vite:config write: true, vite:config emptyOutDir: null, vite:config manifest: false, vite:config lib: false, vite:config ssr: false vite:config }, vite:config env: { BASE_URL: ‘/’, MODE: ‘development’, DEV: true, PROD: false }, vite:config assetsInclude: [Function: assetsInclude], vite:config logger: { vite:config info: [Function: info], vite:config warn: [Function: warn], vite:config error: [Function: error], vite:config clearScreen: [Function: clearScreen] vite:config } vite:config } +9ms vite:optimize Hash is consistent. Skipping. Use --force to override. +0ms
Vite dev server running at:
Network: http://192.168.3.2:3000/ Network: http://192.168.56.1:3000/ Local: http://localhost:3000/
ready in 494ms.
vite:time 8ms / +0ms vite:time 2ms / +4ms vite:time 1ms / +3ms vite:time 1ms / +2ms vite:spa-fallback Rewriting GET / to /index.html +0ms vite:time 4ms /index.html +56ms vite:spa-fallback Rewriting GET / to /index.html +6ms vite:time 2ms /index.html +5ms vite:resolve 2ms /@vite/client -> /Users/nexxus/Desktop/sdsds/my-vite/node_modules/vite/dist/client/client.js +0ms vite:load 5ms [fs] /@vite/client +0ms vite:transform 6ms /@vite/client +0ms vite:time 51ms /@vite/client +91ms vite:resolve 0ms /src/main.js -> /Users/nexxus/Desktop/sdsds/my-vite/src/main.js +61ms vite:cache [304] /@vite/client +0ms vite:time 32ms /@vite/client +77ms vite:load 69ms [fs] /src/main.js +152ms vite:resolve 0ms vue -> /Users/nexxus/Desktop/sdsds/my-vite/node_modules/.vite/vue.495389a4.js +129ms vite:resolve 0ms /node_modules/.vite/vue.495389a4.js -> /Users/nexxus/Desktop/sdsds/my-vite/node_modules/.vite/vue.495389a4.js +49ms vite:resolve 0ms ./App.vue -> /Users/nexxus/Desktop/sdsds/my-vite/src/App.vue +4ms vite:resolve 1ms /src/App.vue -> /Users/nexxus/Desktop/sdsds/my-vite/src/App.vue +2ms vite:resolve 0ms vue3-highcharts -> /Users/nexxus/Desktop/sdsds/my-vite/node_modules/.vite/vue3-highcharts.e429632c.js +0ms vite:resolve 1ms /node_modules/.vite/vue3-highcharts.e429632c.js -> /Users/nexxus/Desktop/sdsds/my-vite/node_modules/.vite/vue3-highcharts.e429632c.js +20ms vite:resolve 0ms highcharts -> /Users/nexxus/Desktop/sdsds/my-vite/node_modules/.vite/highcharts.7ef7813e.js +5ms vite:resolve 0ms /node_modules/.vite/highcharts.7ef7813e.js -> /Users/nexxus/Desktop/sdsds/my-vite/node_modules/.vite/highcharts.7ef7813e.js +1ms 16:41:30 [vite] Internal server error: Deep import “highcharts/modules/stock” should be avoided because dependency “highcharts” has been pre-optimized. Prefer importing directly from the module entry:
import { … } from “highcharts”
If the used import is not exported from the package’s main entry and can only be attained via deep import, you can explicitly add the deep import path to “optimizeDeps.include” in vite.config.js.
Plugin: vite:import-analysis
File: /Users/nexxus/Desktop/sdsds/my-vite/src/main.js
at tryNodeResolve (C:\XXXX\XXXXX\XXXX\XXXX\my-vite\node_modules\vite\dist\node\chunks\dep-baca5bcc.js:40043:15)
at Context.resolveId (C:\XXXX\XXXXX\XXXX\XXXX\my-vite\node_modules\vite\dist\node\chunks\dep-baca5bcc.js:39962:28)
at Object.resolveId (C:\XXXX\XXXXX\XXXX\XXXX\my-vite\node_modules\vite\dist\node\chunks\dep-baca5bcc.js:52856:53)
at TransformContext.resolve (C:\XXXX\XXXXX\XXXX\XXXX\my-vite\node_modules\vite\dist\node\chunks\dep-baca5bcc.js:52646:23)
at normalizeUrl (C:\XXXX\XXXXX\XXXX\XXXX\my-vite\node_modules\vite\dist\node\chunks\dep-baca5bcc.js:45925:34)
at TransformContext.transform (C:\XXXX\XXXXX\XXXX\XXXX\my-vite\node_modules\vite\dist\node\chunks\dep-baca5bcc.js:46042:57)
at Object.transform (C:\XXXX\XXXXX\XXXX\XXXX\my-vite\node_modules\vite\dist\node\chunks\dep-baca5bcc.js:52920:30)
at transformRequest (C:\XXXX\XXXXX\XXXX\XXXX\my-vite\node_modules\vite\dist\node\chunks\dep-baca5bcc.js:59172:29)
at C:\XXXX\XXXXX\XXXX\XXXX\my-vite\node_modules\vite\dist\node\chunks\dep-baca5bcc.js:59258:32
vite:time 242ms /src/main.js +178ms
vite:load 2ms [fs] /src/main.js +150ms
16:41:30 [vite] Internal server error: Deep import “highcharts/modules/stock” should be avoided because dependency “highcharts” has been pre-optimized. Prefer importing directly from the module entry:
import { … } from “highcharts”
If the used import is not exported from the package’s main entry and can only be attained via deep import, you can explicitly add the deep import path to “optimizeDeps.include” in vite.config.js. Plugin: vite:import-analysis File: /Users/nexxus/Desktop/sdsds/my-vite/src/main.js at tryNodeResolve (C:\XXXX\XXXXX\XXXX\XXXX\my-vite\node_modules\vite\dist\node\chunks\dep-baca5bcc.js:40043:15) at Context.resolveId (C:\XXXX\XXXXX\XXXX\XXXX\my-vite\node_modules\vite\dist\node\chunks\dep-baca5bcc.js:39962:28) at Object.resolveId (C:\XXXX\XXXXX\XXXX\XXXX\my-vite\node_modules\vite\dist\node\chunks\dep-baca5bcc.js:52856:53) at TransformContext.resolve (C:\XXXX\XXXXX\XXXX\XXXX\my-vite\node_modules\vite\dist\node\chunks\dep-baca5bcc.js:52646:23) at normalizeUrl (C:\XXXX\XXXXX\XXXX\XXXX\my-vite\node_modules\vite\dist\node\chunks\dep-baca5bcc.js:45925:34) at TransformContext.transform (C:\XXXX\XXXXX\XXXX\XXXX\my-vite\node_modules\vite\dist\node\chunks\dep-baca5bcc.js:46042:57) at Object.transform (C:\XXXX\XXXXX\XXXX\XXXX\my-vite\node_modules\vite\dist\node\chunks\dep-baca5bcc.js:52920:30) at transformRequest (C:\XXXX\XXXXX\XXXX\XXXX\my-vite\node_modules\vite\dist\node\chunks\dep-baca5bcc.js:59172:29) at C:\XXXX\XXXXX\XXXX\XXXX\my-vite\node_modules\vite\dist\node\chunks\dep-baca5bcc.js:59258:32 (x2) vite:time 35ms /src/main.js +40ms vite:time 6ms /favicon.ico +18ms vite:time 1ms /favicon.ico +42ms`
I appreciate if someone could help, thank you
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Top GitHub Comments
It’s working correctly for me after beta.29. Try starting the dev server with
--force
+ disabling cache in browser devtools.Problem fixed, it was my browser cache. Thank you so much.