question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[vite] Failed to resolve module import "vue.js".

See original GitHub issue

Describe the bug

I am struggling with this error for a whole day… 截屏2020-07-28 19 50 25 截屏2020-07-28 19 51 04

I cannot find vue.js module in devtools->Application->Feames->Scripts, but found vue.runtime.esm-bundler.js 截屏2020-07-28 19 53 40

Reproduction

Please provide a link to a repo that can reproduce the problem you ran into.

A reproduction is required unless you are absolutely sure that the the problem is obvious and the information you provided is enough for us to understand what the problem is. If a report has only vague description (e.g. just a generic error message) and has no reproduction, it will be closed immediately.

System Info

  • required vite version: 1.0.0.rc.1
  • required Operating System: macOS 10.15
  • required Node version: 10.12
  • Optional:
    • npm/yarn version
    • Installed vue version (from yarn.lock or package-lock.json)
    • Installed @vue/compiler-sfc version 截屏2020-07-28 19 55 45

Logs (Optional if provided reproduction)

截屏2020-07-28 19 56 26

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
ais-onecommented, Jul 29, 2020

Reproduction Repo: https://github.com/Auxxxxlx/exampleG6

I got something new. If you delete vue in dependencies(package.json), like:

{
  "name": "etstt",
  "version": "0.0.0",
  "scripts": {
    "dev": "vite",
    "build": "vite build"
  },
  "dependencies": {},
  "devDependencies": {
    "@vue/compiler-sfc": "^3.0.0-rc.1",
    "vite": "^1.0.0-rc.1"
  }
}

Then you can start the app with no error.

But if you add vue in dependencies, like:

{
  "name": "etstt",
  "version": "0.0.0",
  "scripts": {
    "dev": "vite",
    "build": "vite build"
  },
  "dependencies": {
    "vue": "^3.0.0-rc.1"
  },
  "devDependencies": {
    "@vue/compiler-sfc": "^3.0.0-rc.1",
    "vite": "^1.0.0-rc.1"
  }
}

Then you will find the following error in console. 截屏2020-07-29 10 47 30


I got it to work… Please do the following…

  1. npm update

  2. vite.config.js - remove everything

module.exports = {
}

One last thing, ant design will not work… using imports as it requires webpack… Same for many other UI frameworks.

Web components work nicely though…

0reactions
yyx990803commented, Jul 29, 2020

If you don’t know what optimizeDeps is doing, it’s best not to disable it… it’s required for some non-esm dependencies to work. But in the case of Vue resolving this is a bug.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ask Question - Stack Overflow
The error is caused by vite,need to add a suffix, that is .vue in vite. Alter mobile-routes.js inside src/router/module
Read more >
failed to resolve module specifier "axios". relative references ...
Fresh install of v26 leads to this error with an import axios from 'axios' was finally able to solve by reverting to a...
Read more >
Beginner having issues with Vite build : r/vuejs - Reddit
I'm new to Vue, and after playing around in-browser I wanted to start ... page fails to load with Failed to resolve module...
Read more >
Nuxt 3 APP Failed to resolve module specifier "Vue" - Support
Hi, i`m trying to deploy a nuxt 3 app and I'm getting a blank page, along with the message: Uncaught TypeError: Failed to...
Read more >
Vite issue using Inertia/React - Laracasts
TypeError : Failed to resolve module specifier ... import { defineConfig } from 'vite'; import laravel from 'laravel-vite-plugin'; import react from ...
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