找不到模块:错误:无法解析“ flag-icon-css”

时间:2019-02-07 13:15:20

标签: laravel npm laravel-mix core-ui

我要在laravel项目中安装此管理面板https://coreui.io/(免费版本)。它包含具有以下依赖项的package.json文件:

    "dependencies": {
    "@coreui/coreui": "^2.1.5",
    "@coreui/coreui-plugin-chartjs-custom-tooltips": "1.2.0",
    "@coreui/icons": "0.3.0",
    "bootstrap": "^4.2.1",
    "chart.js": "2.7.3",
    "core-js": "^2.6.1",
    "flag-icon-css": "^3.2.1",
    "font-awesome": "4.7.0",
    "jquery": "3.3.1",
    "pace-progress": "1.0.2",
    "perfect-scrollbar": "^1.4.0",
    "popper.js": "^1.14.6",
    "simple-line-icons": "2.4.1"
  },

因此,我将把这些依赖项放入package.json中并运行 npm installnpm run dev。我项目的packaje.json是

{
  "private": true,
  "scripts": {
    "dev": "npm run development",
    "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "npm run development -- --watch",
    "watch-poll": "npm run watch -- --watch-poll",
    "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "prod": "npm run production",
    "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  },
  "dependencies": {
    "@coreui/coreui": "^2.1.6",
    "@coreui/coreui-plugin-chartjs-custom-tooltips": "1.2.0",
    "@coreui/icons": "0.3.0",
    "bootstrap": "^4.2.1",
    "chart.js": "2.7.3",
    "core-js": "^2.6.1",
    "flag-icon-css": "^3.2.1",
    "font-awesome": "^4.7.0",
    "jquery": "3.3.1",
    "node-sass": "^4.11.0",
    "pace": "*",
    "pace-progress": "1.0.2",
    "perfect-scrollbar": "^1.4.0",
    "popper.js": "^1.14.6",
    "simple-line-icons": "^2.4.1"
  },
  "devDependencies": {
    "axios": "^0.18",
    "bootstrap": "^4.0.0",
    "cross-env": "^5.1",
    "css-loader": "^2.1.0",
    "jquery": "^3.2",
    "laravel-mix": "^4.0.7",
    "lodash": "^4.17.5",
    "popper.js": "^1.12",
    "resolve-url-loader": "^2.3.1",
    "sass": "^1.15.2",
    "sass-loader": "^7.1.0",
    "style-loader": "^0.23.1",
    "vue": "^2.5.17",
    "vue-template-compiler": "^2.6.3"
  }
}

但是结果是我看到以下内容:

enter image description here

那么,我该如何解决?怎么了?

1 个答案:

答案 0 :(得分:0)

首先,请确保您已成功安装所有软件包。我个人建议您删除node_modules,然后运行npm install

我认为问题是您的项目没有找到它的CSS / SASS依赖项。 确保将所有CSS / SASS文件导入到您的app.scss文件中。 例如,对于“简单线条图标”包,您应该执行以下操作。

@import "~simple-line-icons/scss/simple-line-icons";

还要仔细检查所有js。组件 例如,在您的app.js

import 'coreui';