0

I am trying to add vue-lazyload to my nuxt.js app, it works locally but when I try to deploy via Netlify I recieve this error.

9:46:04 PM: [fatal] Nuxt build error
9:46:04 PM:   ERROR in ./plugins/vue-lazyload.js
9:46:04 PM:   Module not found: Error: Can't resolve 'vue-lazyload' in 'plugins'
   @ ./plugins/vue-lazyload.js 2:0-39 5:8-19

My vue-lazyload.js file can be found in ./plugins alongside my other plugins and I don't get this error on my local host. Here is the vue-lazyload.js

 import Vue from "vue";
 import VueLazyLoad from "vue-lazyload";

 import error from "../assets/error.svg";
 import loading from "../assets/loading.svg";

 Vue.use(VueLazyLoad, {
    preLoad: 1,
    error: error,
    loading: loading,
    attempt: 1
 });

Here is the plugins section from my nuxt.config.js

plugins: [
    { src: '~/plugins/uikit.js', ssr: false },
    { src: '~/plugins/vue-agile.js', ssr: false },
    { src: '~/plugins/vue-awesome.js', ssr: false },
    { src: '~/plugins/vue-lazyload.js', ssr: false }
],

I seen on another Stack question Netlify sometimes has case issues with component names but I checked my github repository and my local files for differing cases within the plugin file name and don't see any problems.

I feel like I have maybe missed something quite trivial but I don't know how to solve this issue or where to look to help figure it out, any help would be appreciated.

EDIT I've created a sample repo of my frontend on github here, it should allow you to see the frontend code which is being used during the production deployment.

EDIT 2 Issue was solved and removing repo link as no longer needed.

fraserky
  • 93
  • 4
  • 22
  • Might be helpful to include a sample repo reproducing it. Your config looks fine to me – HMilbradt Jul 16 '20 at 02:08
  • I've set up a sample repo containing my frontend code [here](https://github.com/KyleSFraser/SampleFrontendPortfolio). It should allow you to browse the files which are being used in the production deployment, is this what you meant? – fraserky Jul 16 '20 at 13:47

1 Answers1

1

There is no vue-lazyload dependency in your package.json, so Netlify can't install it, just run this command npm install --save vue-lazyload

  • Thanks very much Victoria that has solved my problem :) I had originally installed `vue-lazyload` with `yarn add`, does this not function the same as `npm install --save` ? – fraserky Jul 17 '20 at 22:11