Can't resolve 'element-plus/lib/locale' in 'E:\Project\demo\src\plugins'???

ducat7 发布于 06/22 14:54
阅读 141
收藏 0

开源之夏第三届火热来袭,高校学生参与赢万元奖金!>>>

求教,这个错误,应该如何解决呢???

Compiled with problems:X

ERROR in ./src/plugins/element.js 1:0-63

Module not found: Error: Can't resolve 'element-plus/lib/dist/el-message.css' in 'E:\Project\demo\src\plugins'


ERROR in ./src/plugins/element.js 2:0-40

Module not found: Error: Can't resolve 'element-plus/lib/dist/base.css' in 'E:\Project\demo\src\plugins'


ERROR in ./src/plugins/element.js 3:0-53

Module not found: Error: Can't resolve 'element-plus/lib/el-message' in 'E:\Project\demo\src\plugins'


ERROR in ./src/plugins/element.js 4:0-70

Module not found: Error: Can't resolve 'element-plus/lib/dist/el-tree-select.css' in 'E:\Project\demo\src\plugins'


ERROR in ./src/plugins/element.js 6:0-60

Module not found: Error: Can't resolve 'element-plus/lib/el-tree-select' in 'E:\Project\demo\src\plugins'


ERROR in ./src/plugins/element.js 9:0-45

Module not found: Error: Can't resolve 'element-plus/lib/locale' in 'E:\Project\demo\src\plugins'


ERROR in ./src/components/header/MenuItem.vue?vue&type=template&id=5a10d694 (./node_modules/unplugin-auto-import/node_modules/unplugin/dist/webpack/loaders/transform.js??ruleSet[1].rules[40].use[0]!./node_modules/unplugin/dist/webpack/loaders/transform.js??ruleSet[1].rules[41].use[0]!./node_modules/babel-loader/lib/index.js??clonedRuleSet-40.use[0]!./node_modules/vue-loader/dist/templateLoader.js??ruleSet[1].rules[4]!./node_modules/vue-loader/dist/index.js??ruleSet[0].use[0]!./src/components/header/MenuItem.vue?vue&type=template&id=5a10d694) 1:109-163

Module not found: Error: Can't resolve 'element-plus/es/components/submenu/style/css' in 'E:\Project\demo\src\components\header'


element.js

import "element-plus/dist/index.css";
import { ElMessage, ElTreeSelect } from "element-plus";
import lang from "element-plus/lib/locale/lang/zh-cn";
import locale from "element-plus/lib/locale";

export default (app) => {
  locale.use(lang);
  app.use(ElTreeSelect);
  app.config.globalProperties.$message = ElMessage({
    duration: 10000,
    showClose: true,
    grouping: true
  });
};


package.json

{
  "name": "demo",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve --open --host localhost",
    "serve:prod": "vue-cli-service serve --open --mode prod --host localhost",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "core-js": "^3.23.2",
    "element-plus": "^2.2.6",
    "vue": "^3.2.13",
    "vue-router": "^4.0.3",
    "vuex": "^4.0.0"
  },
  "devDependencies": {
    "@layui/layui-vue": "^1.1.10",
    "@typescript-eslint/eslint-plugin": "^5.29.0",
    "@typescript-eslint/parser": "^5.29.0",
    "@vue/cli-plugin-babel": "~5.0.0",
    "@vue/cli-plugin-eslint": "~5.0.0",
    "@vue/cli-plugin-router": "~5.0.0",
    "@vue/cli-plugin-typescript": "~5.0.0",
    "@vue/cli-plugin-vuex": "~5.0.0",
    "@vue/cli-service": "~5.0.0",
    "@vue/eslint-config-typescript": "^9.1.0",
    "axios": "^0.27.2",
    "babel-plugin-component": "^1.1.1",
    "eslint": "^7.32.0",
    "eslint-plugin-vue": "^8.0.3",
    "mitt": "^3.0.0",
    "sass": "^1.32.7",
    "sass-loader": "^12.0.0",
    "typescript": "~4.5.5",
    "unplugin-auto-import": "^0.8.8",
    "unplugin-vue-components": "^0.19.6",
    "vue-baidu-map-3x": "^1.0.16",
    "vue-cli-plugin-element-plus": "^0.0.13"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/vue3-essential",
      "eslint:recommended",
      "@vue/typescript/recommended"
    ],
    "parserOptions": {
      "ecmaVersion": 2020
    },
    "rules": {
      "no-console": "off",
      "no-debugger": "off",
      "vue/no-multiple-template-root": "off",
      "no-unused-vars": "off",
      "vue/require-default-prop": "off",
      "vue/multi-word-component-names": "off",
      "@typescript-eslint/no-explicit-any": "off",
      "@typescript-eslint/no-unused-vars": "off",
      "@typescript-eslint/no-var-requires": "off"
    }
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not dead",
    "not ie 11"
  ]
}


babel.config.js

module.exports = {
  "presets": [
    "@vue/cli-plugin-babel/preset"
  ],
  "plugins": [
    [
      "component",
      {
        "libraryName": "element-plus",
        "styleLibraryName": "theme-chalk"
      }
    ]
  ]
};

 

vue.config.js

const { defineConfig } = require("@vue/cli-service");
const AutoImport = require("unplugin-auto-import/webpack");
const Components = require("unplugin-vue-components/webpack");
const {
  ElementPlusResolver,
  LayuiVueResolver
} = require("unplugin-vue-components/resolvers");

module.exports = defineConfig({
  transpileDependencies: true,
  configureWebpack: {
    plugins: [
      AutoImport({
        resolvers: [
          ElementPlusResolver(),
          LayuiVueResolver({ resolveIcons: true })
        ]
      }),
      Components({
        resolvers: [
          ElementPlusResolver(),
          LayuiVueResolver({ resolveIcons: true })
        ]
      })
    ],
    module: {
      rules: [{
          test: /\.mjs$/,
          include: /node_modules/,
          type: "javascript/auto"
      }]
    }
  }
});

 

加载中
OSCHINA
登录后可查看更多优质内容
返回顶部
顶部
返回顶部
顶部