Module not found: Error: Can't resolve VueJS and Laravel 7

370 Views Asked by At

I have a Laravel project and I want to import library from github to my vue component.

Firstly my package.json

{
"private": true,
"scripts": {
    "dev": "npm run development",
    "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --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 --disable-host-check --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 --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"devDependencies": {
    "axios": "^1.5.0",
    "bootstrap": "^4.0.0",
    "cross-env": "^7.0",
    "jquery": "^3.2",
    "laravel-mix": "^6.0.49",
    "lodash": "^4.17.19",
    "popper.js": "^1.12",
    "resolve-url-loader": "^5.0.0",
    "sass": "^1.20.1",
    "sass-loader": "^8.0.0",
    "vue": "^2.7.14",
    "vue-loader": "^15.9.8",
    "vue-template-compiler": "^2.7.14"
},
"dependencies": {
    "vuejs-image-gallery": "^0.1.6"
}

}

Secondly my webpack.mix.js

const mix = require('laravel-mix');

mix.js('resources/js/app.js', 'public/js')
    .vue({version: 2})
    .sass('resources/sass/app.scss', 'public/css');

And finally my vue component

<template>
<div>
    <Gallery
        :images="images"
        :imageWidth="720"
        :imageHeight="auto"
        :popUpMaxWidth="720"
        :mdCols="4"
        :smCols="4"
        :xsCols="6"
        :lgCols="2"
    />
</div>
<script>
    import Gallery from 'vuejs-image-gallery';
    export default {
        mounted() {
            console.log('Component mounted.')
        }
    }
</script>

But when I try to do npm run dev I got the problem

ERROR in ./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js& (./node_modules/babel-loader/lib/index.js??clonedRuleSet-5.use[0]!./node_modules/vue-loader/lib/index.js??vue-loader-options!./resources/js/components/ExampleComponent.vue?vue&type=script&lang=js&) 1:0-42

Module not found: Error: Can't resolve 'vuejs-image-gallery' in '/var/www/html/blog/resources/js/components' Did you miss the leading dot in 'resolve.extensions'? Did you mean '[".",".wasm",".mjs",".js",".jsx",".json",".vue"]' instead of '["",".wasm",".mjs",".js",".jsx",".json",".vue"]'?

webpack compiled with 1 error

What can I do to fix it?

0

There are 0 best solutions below