vue-loader:找不到模块

Posted

技术标签:

【中文标题】vue-loader:找不到模块【英文标题】:vue-loader: Module was not found 【发布时间】:2020-01-29 00:38:14 【问题描述】:

我找不到这个module was not found错误的问题。

未找到此相关模块:

./graphics/logo.svg in ./node_modules/cache-loader/dist/cjs.js?"cacheDirectory":"node_modules/.cache/vue-loader","cacheIdentifier":"259fb446-vue- loader-template"!./node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/vuetify-loader/lib/loader.js!./node_modules/cache-loader /dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/Home.vue?vue&type=template&id=8dc7cce2&scoped=true&

我的 package.json:


  "name": "app",
  "version": "0.1.0",
  "private": false,
  "scripts": 
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  ,
  "dependencies": 
    "core-js": "^3.2.1",
    "firebase": "^7.0.0",
    "material-icons": "^0.3.1",
    "register-service-worker": "^1.6.2",
    "vue": "^2.6.10",
    "vue-flickity": "^1.2.1",
    "vue-router": "^3.1.3",
    "vuetify": "^2.0.19",
    "vuex": "^3.1.1"
  ,
  "devDependencies": 
    "@mdi/font": "^4.4.95",
    "@vue/cli-plugin-babel": "^3.11.0",
    "@vue/cli-plugin-eslint": "^3.11.0",
    "@vue/cli-plugin-pwa": "^3.11.0",
    "@vue/cli-service": "^3.11.0",
    "@vue/eslint-config-prettier": "^5.0.0",
    "babel-eslint": "^10.0.3",
    "eslint": "^6.5.0",
    "eslint-plugin-prettier": "^3.1.1",
    "eslint-plugin-vue": "^5.2.3",
    "material-design-icons-iconfont": "^5.0.1",
    "node-sass": "^4.12.0",
    "prettier": "1.18.2",
    "sass-loader": "^8.0.0",
    "stylus": "^0.54.7",
    "stylus-loader": "^3.0.2",
    "uglifyjs-webpack-plugin": "^2.2.0",
    "vue-cli-plugin-vuetify": "^0.6.3",
    "vue-loader": "^15.7.1",
    "vue-template-compiler": "^2.6.10",
    "vuetify-loader": "^1.3.0",
    "webpack": "^4.41.0",
    "webpack-cli": "^3.3.9"
  ,
  "eslintConfig": 
    "root": true,
    "env": 
      "node": true
    ,
    "extends": [
      "plugin:vue/essential",
      "@vue/prettier"
    ],
    "rules": 
      "no-console": "off"
    ,
    "parserOptions": 
      "parser": "babel-eslint"
    
  ,
  "postcss": 
    "plugins": 
      "autoprefixer": 
    
  ,
  "browserslist": [
    "> 1%",
    "last 2 versions"
  ]

我正在使用 @vue/cli@3.11.0。 我尝试多次删除 package-lock.json/node_modules 并在之后运行 npm install 。没有什么能解决它 - 甚至更新 Vue CLI 和全局的所有包。

【问题讨论】:

./graphics/logo.svg 是否存在于您的项目文件夹中? @madflow 是的,你是对的,错误与缺少 svg 加载器无关 是的,它存在于文件夹中。 既然您已经通过删除 node_modules 完成了文档所说的cli.vuejs.org/guide/… - 远程调试技能对我来说结束了。我需要一些代码,例如带有相关代码的最小存储库。也许完全禁用缓存加载器并检查问题是否仍然存在? 【参考方案1】:

把图片放到 src/assets 文件夹里,像这样输入 <img src="~@/assets/images.jpg/>

【讨论】:

以上是关于vue-loader:找不到模块的主要内容,如果未能解决你的问题,请参考以下文章

vue教程3-07 vue-loader

vue23:vue-loader

无法配置 css 模块以使用 vue-loader

vue-loader 的深入用法

带有打字稿的VueJS单文件组件:找不到模块stuff.vue

Vue + Webpack + Vue-loader 功能介绍