Module not found: Error: Can't resolve 'flag-icon-css' in - laravel

I am going to install this admin panel https://coreui.io/ (free version) in my laravel project. It contains a package.json file with the following dependencies:
"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"
},
So I am just going to put these dependencies in my package.json and run
npm install and npm run dev. My project's packaje.json is
{
"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"
}
}
But as result I see the following:
So, how I can fix it? What is wrong?

First of all ensure you have installed all packages successfully. I personally recommend you delete your node_modules then run npm install.
I think the problem is that your project doesn't found it's CSS/SASS dependencies.
Ensure to import all CSS/SASS files into your app.scss file.
For example for Simple Line Icons package you should do something like this.
#import "~simple-line-icons/scss/simple-line-icons";
Also double check all js. components
For example in your app.js
import 'coreui';

Related

Laravel Mix Critical CSS - criticalCss is not a function

I have been trying to compile Webpack with laravel-mix, laravel-mix-purgecss, and laravel-mix-criticalcss. But I have been facing issues compiling it with laravel-mix-criticalcss. If I comment the criticalcss in webpack.mix.js, it works fine, but with criticalcss it throws an error. I have upgraded npm and all packages, but whenever I try to compile webpack, it throws this error:
[webpack-cli] TypeError:
mix.js(...).options(...).postCss(...).options(...).sass(...).sass(...).criticalCss
is not a function
I have included laravel-mix-criticalcss in webpack.mix.js
require('laravel-mix-criticalcss');
package.json
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production"
},
"dependencies": {
"intersection-observer": "^0.12.0",
"laravel-vue-pagination": "^3.0.0",
"sass-migrator": "^1.5.4",
"v-lazy-image": "^2.1.1",
"vanilla-lazyload": "^17.6.1",
"vue-clickaway": "^2.2.2",
"vue-slider-component": "^3.2.15",
"vue-sweetalert2": "^5.0.2",
"vuedraggable": "^2.24.3"
},
"devDependencies": {
"autoprefixer": "^10.4.4",
"axios": "^0.26.1",
"bootstrap": "^4.6.0",
"bs-custom-file-input": "^1.3.4",
"cross-env": "^7.0.3",
"jquery": "^3.6.0",
"laravel-mix": "^6.0.43",
"laravel-mix-criticalcss": "^0.1.0",
"laravel-mix-purgecss": "^6.0.0",
"laravel-mix-workbox": "^0.1.4",
"livewire-sortable": "^0.2.2",
"lodash": "^4.17.21",
"popper.js": "^1.16.1",
"postcss": "^8.4.12",
"resolve-url-loader": "^5.0.0",
"sass": "^1.49.9",
"sass-loader": "^12.6.0",
"tailwindcss": "^3.0.23",
"vue": "^3.2.31",
"vue-template-compiler": "^2.6.14",
"workbox-webpack-plugin": "^6.5.1"
}
}
Try using a new version of Laravel Mix Critical.
npm i laravel-mix-criticalcss#latest --save-dev
Or use this package.json and do npm install.
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production"
},
"dependencies": {
"intersection-observer": "^0.12.0",
"laravel-vue-pagination": "^3.0.0",
"sass-migrator": "^1.5.4",
"v-lazy-image": "^2.1.1",
"vanilla-lazyload": "^17.6.1",
"vue-slider-component": "^3.2.15",
"vue-sweetalert2": "^5.0.2",
"vuedraggable": "^2.24.3"
},
"devDependencies": {
"autoprefixer": "^10.4.4",
"axios": "^0.26.1",
"bootstrap": "^4.6.0",
"bs-custom-file-input": "^1.3.4",
"cross-env": "^7.0.3",
"jquery": "^3.6.0",
"laravel-mix": "^6.0.43",
"laravel-mix-criticalcss": "^1.0.2",
"laravel-mix-purgecss": "^6.0.0",
"laravel-mix-workbox": "^0.1.4",
"livewire-sortable": "^0.2.2",
"lodash": "^4.17.21",
"popper.js": "^1.16.1",
"postcss": "^8.4.12",
"resolve-url-loader": "^5.0.0",
"sass": "^1.49.9",
"sass-loader": "^12.6.0",
"tailwindcss": "^3.0.23",
"vue": "^3.2.31",
"vue-template-compiler": "^2.6.14",
"workbox-webpack-plugin": "^6.5.1"
}
}

Problem with Vue: Module build failed (from ./node_modules/mini-css-extract-plugin/dist/loader.js)

I recently updated my repositories, and now I'm having these issues every time I build.
I already tried to go back to the previous point, but still the same. I found a problem with the style sheet. I use Tailwind, and when I import a sheet inside app.css if this sheet has these classes:
transform -translate-x-1/2 translate-y-1/2 can't compile
I took those classes out and put them in app.css, but when I use npm run watch, it compiles the first time, but if I do another modification, I have to save app.css again to compile correctly.
ERROR in ./resources/css/app.css
(./node_modules/css-loader/dist/cjs.js??clonedRuleSet-6.use[1]!./node_modules/postcss-loader/dist/cjs.js??clonedRuleSet-6.use[2]!./resources/css/app.css)
Module build failed (from ./node_modules/postcss-loader/dist/cjs.js):
Problem with Vue building Module build failed (from
./node_modules/mini-css-extract-plugin/dist/loader.js)
package.json
{
"private": true,
"scripts": {
"lint": "eslint --ext .js,.vue resources/js/",
"dev": "npm run development",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production"
},
"devDependencies": {
"#types/sanitize-html": "^2.3.2",
"#vue/compiler-sfc": "^3.1.4",
"autoprefixer": "^10.4.0",
"axios": "^0.21",
"cssnano": "^5.0.7",
"eslint": "^7.31.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier-vue": "^3.1.0",
"eslint-plugin-vue": "^7.14.0",
"laravel-mix": "^6.0.42",
"lodash": "^4.17.19",
"mini-css-extract-plugin": "^1.6.2",
"postcss": "^8.4.5",
"postcss-import": "^14.0.2",
"postcss-loader": "^6.2.1",
"prettier": "^2.3.2",
"tailwindcss": "^3.0.23",
"vue-loader": "^16.3.0"
},
"dependencies": {
"#chenfengyuan/vue-barcode": "^2.0.0-beta",
"#fortawesome/fontawesome-svg-core": "^1.2.35",
"#fortawesome/free-brands-svg-icons": "^5.15.4",
"#fortawesome/free-solid-svg-icons": "^5.15.3",
"#fortawesome/vue-fontawesome": "^3.0.0-4",
"ag-grid-community": "^25.3.0",
"ag-grid-vue3": "^25.3.1",
"click-outside-vue3": "^4.0.1",
"dayjs": "^1.10.7",
"jsbarcode": "^3.11.4",
"laravel-echo": "^1.11.3",
"mini-css-extract-plugin": "^2.5.3",
"pusher-js": "^7.0.6",
"peru-ubigeo": "^0.0.3",
"qrcode.vue": "^3.2.2",
"quagga": "^0.12.1",
"twitter-widgets": "^2.0.0",
"vue": "^3.1.5",
"vue-3-sanitize": "^0.1.3",
"vue-class-component": "^8.0.0-rc.1",
"vue-cookie-next": "^1.0.3",
"vue-currency-input": "^2.0.0",
"vue-debounce": "^3.0.1",
"vue-router": "^4.0.12",
"vue-upload-drop-images": "^1.0.7",
"vue2-datepicker": "^4.0.0-beta.2",
"vuex": "^4.0.2"
}
I use Vue 3 and Laravel 8

This relative module was not found: * ./src/main.js in multi ./src/main.js

npm run build error!
I try all solutions for this problem but still not able to solve this. Many times i reinstall npm but not get proper solution (Laravel 8 and Vue js) enter image description here
My package.json Code
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "mix",
"watch": "mix watch",
"watch-poll": "mix watch -- --watch-options-poll=1000",
"hot": "mix watch --hot",
"prod": "npm run production",
"production": "mix --production",
"serve": "vue-cli-service serve",
"build": "vue-cli-service build"
},
"devDependencies": {
"#webpack-cli/init": "^1.1.3",
"axios": "^0.21.1",
"babel-loader": "^8.2.2",
"bootstrap": "^4.6.0",
"jquery": "^3.6",
"laravel-mix": "^6.0.13",
"lodash": "^4.17.21",
"popper.js": "^1.12",
"postcss": "^8.2.8",
"resolve-url-loader": "^3.1.2",
"sass": "^1.32.8",
"sass-loader": "^11.0.1",
"vue": "^2.6.12",
"vue-loader": "^15.9.6",
"vue-template-compiler": "^2.6.12",
"webpack": "^5.28.0",
"webpack-cli": "^4.6.0"
},
"dependencies": {
"vue": "^2.6.12",
"vue-router": "^3.5.1"
}
}
I created a src folder(inside root) with a blank main.js file and it worked for me: reference is here

Issue with babel dynamic imports and laravel-mix

when running npm run watch I get the following warning which makes compilation fail.
WARNING in ./resources/js/app.js 19:9-58
System.import() is deprecated and will be removed soon. Use import() instead.
For more info visit https://webpack.js.org/guides/code-splitting/
# multi ./resources/js/app.js ./resources/sass/app.scss /js/app[0]
This is my package.json file:
{
"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"
},
"devDependencies": {
"#babel/plugin-syntax-dynamic-import": "^7.2.0",
"babel-eslint": "^8.2.6",
"babel-plugin-dynamic-import-webpack": "^1.1.0",
"babel-preset-env": "^1.7.0",
"bootstrap": "^4.0.0",
"cross-env": "^5.1",
"laravel-mix": "^4.0.14",
"popper.js": "^1.12",
"resolve-url-loader": "^2.3.1",
"sass": "^1.17.2",
"sass-loader": "^7.1.0"
},
"dependencies": {
"vue": "^2.6.7",
"vue-template-compiler": "^2.6.7",
"axios": "^0.18",
"jquery": "^3.2",
"lodash": "^4.17.4",
"tomtom-sdk": "^1.0.0",
"vue-moment": "^4.0.0",
"vue-parallaxy": "^1.1.1",
"vue2-datepicker": "^2.6.4",
"vue2-editor": "^2.6.6",
"vuex": "^3.1.0",
"vuex-persistedstate": "^2.5.4"
}
}
My .babelrc file which is currently inside my .vscode folder, dunno if that's the best place...
{
"plugins": ["#babel/plugin-syntax-dynamic-import"]
}
OF COURSE if I remove System.import for import I get the following error:
https://i.imgur.com/UEhxaOh.png
which doesn't makes much sense to me since I have already added the plugins section to my babelrc file...
You're not attach your webpack.mix.js config. But I think your problem will solve with the link below.
Laravel-mix Webpack Public Path

Laravel 5.4 mix npm run dev error

So I have a laravel 5.4 project and when I run npm install dev I get the following error
dev: node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
This is my package.json
{
"private": true,
"scripts": {
"dev": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch-poll": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --watch-poll --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"hot": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
"production": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"devDependencies": {
"axios": "^0.15.3",
"bootstrap-sass": "^3.3.7",
"jquery": "^3.1.1",
"laravel-elixir-webpack-react": "^1.0.1",
"laravel-mix": "^0.8.1",
"lodash": "^4.17.4",
"react": "^15.4.2",
"react-dom": "^15.4.2",
"vue": "^2.1.10"
}
}
Why I get this error ?
run this command :
npm install --global cross-env
and also add "gulp": "^3.9.1" in your package.josn under "devDependencies"
This may help you
I have the same problem and y fix it replacing my package.json with this
{
"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"
},
"devDependencies": {
"axios": "^0.18",
"bootstrap": "^4.0.0",
"jquery": "^3.2",
"laravel-mix": "^2.0",
"lodash": "^4.17.5",
"popper.js": "^1.12",
"vue": "^2.5.7",
"autoprefixer": "^7.1.2",
"babel-core": "^6.26.3",
"babel-eslint": "^7.1.1",
"babel-loader": "^7.1.1",
"babel-plugin-component": "^1.1.0",
"babel-plugin-istanbul": "^4.1.1",
"babel-plugin-transform-runtime": "^6.22.0",
"babel-preset-env": "^1.6.0",
"babel-polyfill": "^6.26.0",
"babel-preset-stage-2": "^6.22.0",
"babel-register": "^6.22.0",
"chai": "^4.1.2",
"chalk": "^2.0.1",
"chromedriver": "^2.27.2",
"compression-webpack-plugin": "^1.0.1",
"connect-history-api-fallback": "^1.3.0",
"copy-webpack-plugin": "^4.1.0",
"cross-env": "^5.0.1",
"cross-spawn": "^5.0.1",
"css-loader": "^0.28.0",
"eslint": "^3.19.0",
"eslint-config-standard": "^10.2.1",
"eslint-friendly-formatter": "^3.0.0",
"eslint-loader": "^1.7.1",
"eslint-plugin-html": "^3.0.0",
"eslint-plugin-import": "^2.6.1",
"eslint-plugin-node": "^4.2.2",
"eslint-plugin-promise": "^3.5.0",
"eslint-plugin-standard": "^3.0.1",
"eventsource-polyfill": "^0.9.6",
"express": "^4.14.1",
"extract-text-webpack-plugin": "^2.0.0",
"file-loader": "^0.11.1",
"friendly-errors-webpack-plugin": "^1.1.3",
"function-bind": "^1.1.0",
"html-webpack-plugin": "^2.28.0",
"http-proxy-middleware": "^0.17.3",
"inject-loader": "^3.0.0",
"karma": "^1.4.1",
"karma-coverage": "^1.1.1",
"karma-mocha": "^1.3.0",
"karma-phantomjs-launcher": "^1.0.2",
"karma-phantomjs-shim": "^1.4.0",
"karma-sinon-chai": "^1.3.1",
"karma-sourcemap-loader": "^0.3.7",
"karma-spec-reporter": "0.0.31",
"karma-webpack": "^2.0.2",
"lolex": "^1.5.2",
"marked": "^0.3.6",
"mocha": "^3.2.0",
"nightwatch": "^0.9.12",
"node-sass": "^4.5.3",
"opn": "^5.1.0",
"optimize-css-assets-webpack-plugin": "^3.2.0",
"ora": "^1.2.0",
"phantomjs-prebuilt": "^2.1.14",
"raw-loader": "^0.5.1",
"sass-loader": "^5.0.1",
"selenium-server": "^3.0.1",
"semver": "^5.3.0",
"shelljs": "^0.7.6",
"sinon": "^2.1.0",
"sinon-chai": "^2.8.0",
"url-loader": "^0.5.8",
"vue-loader": "^13.0.4",
"vue-style-loader": "^3.0.1",
"vue-template-compiler": "^2.5.2",
"vue-test-utils": "^1.0.0-beta.3",
"webpack": "^3.2.0",
"webpack-bundle-analyzer": "^2.2.1",
"webpack-dev-middleware": "^1.10.0",
"webpack-hot-middleware": "^2.18.0",
"webpack-merge": "^4.1.0"
},
"dependencies": {
"chartist": "^0.11.0",
"easy-pie-chart": "^2.1.7",
"element-ui": "^2.0.3",
"fullcalendar": "^3.6.2",
"google-maps": "^3.2.1",
"jquery": "^3.2.1",
"jvectormap-next": "^3.0.0",
"perfect-scrollbar": "0.7.1",
"sweetalert2": "^6.11.4",
"vee-validate": "^2.0.0-rc.21",
"vue": "^2.5.2",
"vue-clickaway": "^2.1.0",
"vue-form-wizard": "^0.7.0",
"vue-nav-tabs": "^0.5.4",
"vue-notifyjs": "^0.2.0",
"vue-router": "^3.0.1"
},
"engines": {
"node": ">= 4.0.0",
"npm": ">= 3.0.0"
}
after, i make this things :
rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
npm install
npm run dev
I hope this can help you.
Because you are trying to install dependencies.
To install devDependencies you could do
npm install --only=dev
To run dev you do
npm run dev

Resources