nuxt: Generate is not work correctly

After running nuxt generate operation, the page of index.html can load correctly. But its JS dependencies aren’t working unless the components locate in the layouts folder. Finally, if the version is oldest, it will work normally.

<div align="right">This question is available on Nuxt.js community (#c1638)</div>

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 1
  • Comments: 17

Most upvoted comments

@SyedAman - I just figured it out! Generating to /dist doesn’t just generate static files that can be opened as HTML files in a browser. You must point a local server (ie. nginx) at the /dist directory and access via the server, such as localhost:8000.

So if you haven’t already, install nginx, then point you nginx.conf’s file’s root location at the /dist folder you want to serve…

server {
    location / {
            root   /Users/gvinter/NUXT_PROJECT/dist;
            index  index.html index.htm;
    }
}

And that works for me!

@gvinter @KermitLi

I didn’t need to use nginx. I fixed it!

Check out: https://nuxtjs.org/api/configuration-router/

I just had to add

  router: {
    base: '/my-github-repository-name/'
  }

and it deployed properly

@KermitLi you should be fine with the fixes mentioned above.