run "vite" get a error "Error: The following dependencies are imported but could not be resolved:"
See original GitHub issueDescribe the bug
error when starting dev server:
Error: The following dependencies are imported but could not be resolved:
virtual:pwa-register (imported by /Users/baboon/github/picx/src/common/utils/registerSW.ts)
Are they installed?
at optimizeDeps (/Users/baboon/github/picx/node_modules/vite/dist/node/chunks/dep-e9a16784.js:64742:15)
at processTicksAndRejections (node:internal/process/task_queues:94:5)
at async runOptimize (/Users/baboon/github/picx/node_modules/vite/dist/node/chunks/dep-e9a16784.js:68555:48)
at async Server.httpServer.listen (/Users/baboon/github/picx/node_modules/vite/dist/node/chunks/dep-e9a16784.js:68569:17)
Reproduction
- npm i
- run
npx vite
- get a error
System Info
Output of npx envinfo --system --npmPackages vite,@vitejs/plugin-vue --binaries --browsers
:
System:
OS: macOS 11.3.1
CPU: (8) arm64 Apple M1
Memory: 379.80 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 15.14.0 - ~/.nvm/versions/node/v15.14.0/bin/node
npm: 7.10.0 - ~/.nvm/versions/node/v15.14.0/bin/npm
Browsers:
Chrome Canary: 92.0.4511.4
Safari: 14.1
npmPackages:
@vitejs/plugin-vue: ^1.1.4 => 1.2.2
vite: ^2.0.1 => 2.3.3
Used package manager: npm
Logs
vite:config bundled config file loaded in 300ms +0ms
[dotenv][DEBUG] did not match key and value when parsing line 1: # port
[dotenv][DEBUG] did not match key and value when parsing line 3:
[dotenv][DEBUG] did not match key and value when parsing line 4: # open browser
[dotenv][DEBUG] did not match key and value when parsing line 6:
[dotenv][DEBUG] did not match key and value when parsing line 7: # cors
[dotenv][DEBUG] did not match key and value when parsing line 9:
[dotenv][DEBUG] did not match key and value when parsing line 10: # use pwa
[dotenv][DEBUG] did not match key and value when parsing line 12:
[dotenv][DEBUG] did not match key and value when parsing line 1: # port
[dotenv][DEBUG] did not match key and value when parsing line 3:
[dotenv][DEBUG] did not match key and value when parsing line 4: # open browser
[dotenv][DEBUG] did not match key and value when parsing line 6:
[dotenv][DEBUG] did not match key and value when parsing line 7: # cors
[dotenv][DEBUG] did not match key and value when parsing line 9:
[dotenv][DEBUG] did not match key and value when parsing line 10: # use pwa
[dotenv][DEBUG] did not match key and value when parsing line 12:
vite:config using resolved config: {
vite:config plugins: [
vite:config 'vite:pre-alias',
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:define',
vite:config 'vite:css-post',
vite:config 'vite:style-import',
vite:config 'vite:client-inject',
vite:config 'vite:import-analysis'
vite:config ],
vite:config resolve: { dedupe: undefined, alias: [ [Object], [Object] ] },
vite:config base: '/',
vite:config server: {
vite:config port: 4000,
vite:config open: true,
vite:config cors: true,
vite:config fsServe: { root: '/Users/baboon/github/picx', strict: false }
vite:config },
vite:config define: { __VUE_OPTIONS_API__: true, __VUE_PROD_DEVTOOLS__: false },
vite:config ssr: { external: [ 'vue', '@vue/server-renderer' ] },
vite:config configFile: '/Users/baboon/github/picx/vite.config.ts',
vite:config configFileDependencies: [
vite:config 'src/plugins/pwa.ts',
vite:config 'src/plugins/styleImport.ts',
vite:config 'src/plugins/index.ts',
vite:config 'src/common/utils/env.ts',
vite:config 'vite.config.ts'
vite:config ],
vite:config inlineConfig: {
vite:config root: undefined,
vite:config base: undefined,
vite:config mode: undefined,
vite:config configFile: undefined,
vite:config logLevel: undefined,
vite:config clearScreen: undefined,
vite:config server: {}
vite:config },
vite:config root: '/Users/baboon/github/picx',
vite:config publicDir: '/Users/baboon/github/picx/public',
vite:config cacheDir: '/Users/baboon/github/picx/node_modules/.vite',
vite:config command: 'serve',
vite:config mode: 'development',
vite:config isProduction: false,
vite:config build: {
vite:config target: [ 'es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1' ],
vite:config polyfillDynamicImport: false,
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 ssrManifest: false,
vite:config brotliSize: true,
vite:config chunkSizeWarningLimit: 500,
vite:config watch: null
vite:config },
vite:config env: {
vite:config VITE_PORT: '4000',
vite:config VITE_OPEN_BROWSER: 'true',
vite:config VITE_CORS: 'true',
vite:config VITE_USE_PWA: 'false',
vite:config BASE_URL: '/',
vite:config MODE: 'development',
vite:config DEV: true,
vite:config PROD: false
vite:config },
vite:config assetsInclude: [Function: assetsInclude],
vite:config logger: {
vite:config hasWarned: false,
vite:config info: [Function: info],
vite:config warn: [Function: warn],
vite:config warnOnce: [Function: warnOnce],
vite:config error: [Function: error],
vite:config clearScreen: [Function: clearScreen]
vite:config },
vite:config createResolver: [Function: createResolver],
vite:config optimizeDeps: { esbuildOptions: { keepNames: undefined } }
vite:config } +4ms
vite:deps Crawling dependencies using entries:
vite:deps /Users/baboon/github/picx/index.html +0ms
vite:resolve 0ms /src/main.ts -> /Users/baboon/github/picx/src/main.ts +0ms
vite:resolve 1ms vue -> /Users/baboon/github/picx/node_modules/vue/dist/vue.runtime.esm-bundler.js +3ms
vite:resolve 0ms /Users/baboon/github/picx/src/common/utils/styleImport -> /Users/baboon/github/picx/src/common/utils/styleImport.ts +0ms
vite:resolve 1ms @/common/utils/styleImport -> /Users/baboon/github/picx/src/common/utils/styleImport.ts +1ms
vite:resolve 0ms /Users/baboon/github/picx/src/router/index -> /Users/baboon/github/picx/src/router/index.ts +0ms
vite:resolve 0ms @/router/index -> /Users/baboon/github/picx/src/router/index.ts +0ms
vite:resolve 1ms /Users/baboon/github/picx/src/store/index -> /Users/baboon/github/picx/src/store/index.ts +1ms
vite:resolve 1ms @/store/index -> /Users/baboon/github/picx/src/store/index.ts +0ms
vite:resolve 0ms ./App.vue -> /Users/baboon/github/picx/src/App.vue +0ms
vite:resolve 0ms /Users/baboon/github/picx/src/common/utils/registerSW -> /Users/baboon/github/picx/src/common/utils/registerSW.ts +1ms
vite:resolve 0ms @/common/utils/registerSW -> /Users/baboon/github/picx/src/common/utils/registerSW.ts +0ms
vite:resolve 2ms vuex -> /Users/baboon/github/picx/node_modules/vuex/dist/vuex.esm-bundler.js +5ms
vite:resolve 3ms vue-router -> /Users/baboon/github/picx/node_modules/vue-router/dist/vue-router.esm-bundler.js +1ms
vite:resolve 3ms element-plus -> /Users/baboon/github/picx/node_modules/element-plus/lib/index.esm.js +0ms
vite:resolve 3ms virtual:pwa-register -> null +0ms
vite:resolve 0ms ./modules/dir-image-list -> /Users/baboon/github/picx/src/store/modules/dir-image-list/index.ts +1ms
vite:resolve 0ms @/components/Main/index.vue -> /Users/baboon/github/picx/src/components/Main/index.vue +0ms
vite:resolve 0ms @/views/Config/index.vue -> /Users/baboon/github/picx/src/views/Config/index.vue +0ms
vite:resolve 1ms ./modules/to-upload-image -> /Users/baboon/github/picx/src/store/modules/to-upload-image/index.ts +2ms
vite:resolve 1ms @/views/Upload/index.vue -> /Users/baboon/github/picx/src/views/Upload/index.vue +0ms
vite:resolve 0ms ./modules/uploaded-image-list -> /Users/baboon/github/picx/src/store/modules/uploaded-image-list/index.ts +0ms
vite:resolve 0ms @/components/Header.vue -> /Users/baboon/github/picx/src/components/Header.vue +0ms
vite:resolve 0ms @/views/Management/index.vue -> /Users/baboon/github/picx/src/views/Management/index.vue +1ms
vite:resolve 0ms ./modules/user-config-info -> /Users/baboon/github/picx/src/store/modules/user-config-info/index.ts +0ms
vite:resolve 1ms @/components/Nav/index.vue -> /Users/baboon/github/picx/src/components/Nav/index.vue +1ms
vite:resolve 0ms ./modules/image-viewer -> /Users/baboon/github/picx/src/store/modules/image-viewer/index.ts +0ms
vite:resolve 0ms @/views/Tutorials/index.vue -> /Users/baboon/github/picx/src/views/Tutorials/index.vue +0ms
vite:resolve 0ms @/components/image-viewer.vue -> /Users/baboon/github/picx/src/components/image-viewer.vue +0ms
vite:resolve 0ms ./modules/upload-area-active -> /Users/baboon/github/picx/src/store/modules/upload-area-active/index.ts +1ms
vite:resolve 1ms /Users/baboon/github/picx/src/store -> /Users/baboon/github/picx/src/store/index.ts +1ms
vite:resolve 1ms @/views/About/index.vue -> /Users/baboon/github/picx/src/views/About/index.vue +0ms
vite:resolve 1ms @/store -> /Users/baboon/github/picx/src/store/index.ts +0ms
vite:resolve 0ms ./modules/upload-settings -> /Users/baboon/github/picx/src/store/modules/upload-settings/index.ts +0ms
vite:resolve 1ms /Users/baboon/github/picx/src/common/model/localStorage.model -> /Users/baboon/github/picx/src/common/model/localStorage.model.ts +5ms
vite:resolve 1ms @/common/model/localStorage.model -> /Users/baboon/github/picx/src/common/model/localStorage.model.ts +0ms
vite:resolve 1ms @/components/Tutorials-step/step1.vue -> /Users/baboon/github/picx/src/components/Tutorials-step/step1.vue +1ms
vite:resolve 2ms @/components/image-card.vue -> /Users/baboon/github/picx/src/components/image-card.vue +2ms
vite:resolve 0ms /Users/baboon/github/picx/src/common/utils/cleanObject -> /Users/baboon/github/picx/src/common/utils/cleanObject.ts +0ms
vite:resolve 0ms @/components/Tutorials-step/step2.vue -> /Users/baboon/github/picx/src/components/Tutorials-step/step2.vue +0ms
vite:resolve 0ms @/common/utils/cleanObject -> /Users/baboon/github/picx/src/common/utils/cleanObject.ts +0ms
vite:resolve 0ms /Users/baboon/github/picx/src/common/utils/fileHandleHelper -> /Users/baboon/github/picx/src/common/utils/fileHandleHelper.ts +1ms
vite:resolve 1ms ./site-count.vue -> /Users/baboon/github/picx/src/components/site-count.vue +0ms
vite:resolve 1ms @/components/to-upload-image-card.vue -> /Users/baboon/github/picx/src/components/to-upload-image-card.vue +0ms
vite:resolve 1ms @/common/utils/fileHandleHelper -> /Users/baboon/github/picx/src/common/utils/fileHandleHelper.ts +0ms
vite:resolve 1ms /Users/baboon/github/picx/src/common/model/dir.model -> /Users/baboon/github/picx/src/common/model/dir.model.ts +1ms
vite:resolve 1ms @/components/Tutorials-step/step3.vue -> /Users/baboon/github/picx/src/components/Tutorials-step/step3.vue +0ms
vite:resolve 1ms @/common/model/dir.model -> /Users/baboon/github/picx/src/common/model/dir.model.ts +0ms
vite:resolve 0ms /Users/baboon/github/picx/src/common/model/externalLink.model -> /Users/baboon/github/picx/src/common/model/externalLink.model.ts +0ms
vite:resolve 0ms ./getType -> /Users/baboon/github/picx/src/common/utils/getType.ts +0ms
vite:resolve 0ms @/components/upload-area.vue -> /Users/baboon/github/picx/src/components/upload-area.vue +0ms
vite:resolve 0ms @/common/model/externalLink.model -> /Users/baboon/github/picx/src/common/model/externalLink.model.ts +0ms
vite:resolve 1ms /Users/baboon/github/picx/src/common/utils/axios -> /Users/baboon/github/picx/src/common/utils/axios/index.ts +2ms
vite:resolve 1ms @/common/utils/axios -> /Users/baboon/github/picx/src/common/utils/axios/index.ts +0ms
vite:resolve 0ms /Users/baboon/github/picx/src/common/model/upload.model -> /Users/baboon/github/picx/src/common/model/upload.model.ts +0ms
vite:resolve 0ms /Users/baboon/github/picx/src/common/utils/generateExternalLink -> /Users/baboon/github/picx/src/common/utils/generateExternalLink.ts +0ms
vite:resolve 0ms @/common/model/upload.model -> /Users/baboon/github/picx/src/common/model/upload.model.ts +0ms
vite:resolve 0ms @/common/utils/generateExternalLink -> /Users/baboon/github/picx/src/common/utils/generateExternalLink.ts +0ms
vite:resolve 0ms /Users/baboon/github/picx/src/common/utils/timeHelper -> /Users/baboon/github/picx/src/common/utils/timeHelper.ts +0ms
vite:resolve 0ms @/common/utils/timeHelper -> /Users/baboon/github/picx/src/common/utils/timeHelper.ts +0ms
vite:resolve 1ms /Users/baboon/github/picx/src/common/utils/getUuid -> /Users/baboon/github/picx/src/common/utils/getUuid.ts +1ms
vite:resolve 1ms @/common/utils/getUuid -> /Users/baboon/github/picx/src/common/utils/getUuid.ts +0ms
vite:resolve 1ms axios -> /Users/baboon/github/picx/node_modules/axios/index.js +2ms
vite:resolve 0ms @/components/selected-info-bar.vue -> /Users/baboon/github/picx/src/components/selected-info-bar.vue +1ms
vite:resolve 0ms /Users/baboon/github/picx/src/common/utils/axios/index -> /Users/baboon/github/picx/src/common/utils/axios/index.ts +1ms
vite:resolve 0ms @/common/utils/axios/index -> /Users/baboon/github/picx/src/common/utils/axios/index.ts +0ms
vite:resolve 0ms ./fileHandleHelper -> /Users/baboon/github/picx/src/common/utils/fileHandleHelper.ts +1ms
vite:resolve 0ms ./getUuid -> /Users/baboon/github/picx/src/common/utils/getUuid.ts +0ms
vite:resolve 0ms ./copy-external-link.vue -> /Users/baboon/github/picx/src/components/copy-external-link.vue +0ms
vite:resolve 0ms /Users/baboon/github/picx/src/common/utils/chooseImg -> /Users/baboon/github/picx/src/common/utils/chooseImg.ts +1ms
vite:resolve 0ms ../model/externalLink.model -> /Users/baboon/github/picx/src/common/model/externalLink.model.ts +0ms
vite:resolve 0ms @/common/utils/chooseImg -> /Users/baboon/github/picx/src/common/utils/chooseImg.ts +0ms
vite:resolve 0ms /Users/baboon/github/picx/src/common/utils/createToUploadImageObject -> /Users/baboon/github/picx/src/common/utils/createToUploadImageObject.ts +1ms
vite:resolve 0ms @/common/utils/createToUploadImageObject -> /Users/baboon/github/picx/src/common/utils/createToUploadImageObject.ts +0ms
vite:resolve 0ms /Users/baboon/github/picx/src/common/utils/paste -> /Users/baboon/github/picx/src/common/utils/paste.ts +1ms
vite:resolve 1ms @/common/utils/paste -> /Users/baboon/github/picx/src/common/utils/paste.ts +1ms
vite:resolve 0ms ./chooseImg -> /Users/baboon/github/picx/src/common/utils/chooseImg.ts +1ms
vite:resolve 0ms /Users/baboon/github/picx/src/common/utils/uploadUrlHandle -> /Users/baboon/github/picx/src/common/utils/uploadUrlHandle.ts +1ms
vite:resolve 0ms @/common/utils/uploadUrlHandle -> /Users/baboon/github/picx/src/common/utils/uploadUrlHandle.ts +0ms
vite:resolve 0ms ./selected-info-bar.vue -> /Users/baboon/github/picx/src/components/selected-info-bar.vue +1ms
vite:deps Scan completed in 62ms: {
vue: '/Users/baboon/github/picx/node_modules/vue/dist/vue.runtime.esm-bundler.js',
vuex: '/Users/baboon/github/picx/node_modules/vuex/dist/vuex.esm-bundler.js',
'vue-router': '/Users/baboon/github/picx/node_modules/vue-router/dist/vue-router.esm-bundler.js',
'element-plus': '/Users/baboon/github/picx/node_modules/element-plus/lib/index.esm.js',
axios: '/Users/baboon/github/picx/node_modules/axios/index.js'
} +50ms
error when starting dev server:
Error: The following dependencies are imported but could not be resolved:
virtual:pwa-register (imported by /Users/baboon/github/picx/src/common/utils/registerSW.ts)
Are they installed?
at optimizeDeps (/Users/baboon/github/picx/node_modules/vite/dist/node/chunks/dep-e9a16784.js:64742:15)
at processTicksAndRejections (node:internal/process/task_queues:94:5)
at async runOptimize (/Users/baboon/github/picx/node_modules/vite/dist/node/chunks/dep-e9a16784.js:68555:48)
at async Server.httpServer.listen (/Users/baboon/github/picx/node_modules/vite/dist/node/chunks/dep-e9a16784.js:68569:17)
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.
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
The following dependencies are imported but could not be ...
The following dependencies are imported but could not be resolved. bnite. app.js. Copy Code import './bootstrap'; import { createApp } from "vue"; ...
Read more >Troubleshooting
Also if there is a dependency loop, a full reload will happen. To solve this, try removing the loop. Build #. Built file...
Read more >Vite complains that material UI icons can not be resolved
I was getting an error about a local file. Same message: The following dependencies are imported but could not be resolved.
Read more >storybook/builder-vite
A plugin to run and build Storybooks with Vite. Latest version: 0.2.6, last published: 9 days ago. Start using @storybook/builder-vite in ...
Read more >Failed to resolve import "vue-router" from "src/ ...
When I run npm run dev I get the following error: vite v2.9.9 dev ... The following dependencies are imported but could not...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I am trying to migrate a webpack project to vite and am facing the same issue. How did you resolve it?
请问你这个问题解决了么?