How to deploy nuxt.js project on cPanel file manager?

1.3k Views Asked by At

I tried many times by run the command npm run build,

It gives me .nuxt folder and

when I run the command npm run generate I got a folder named dist

Please let me know how and what to do, to upload web application on Cpanel file manager?

1

There are 1 best solutions below

0
On

if you're using ssr you should use npm run build or better build your app first on local, then upload the entire file include node_modules but .env file or only .nuxt, node_modules, nuxt.config.js, package.json. then make a new "app.js" file on your app root folder with:

   const { Nuxt, Builder } = require('nuxt');
   const app = require('express')();
   const port = process.env.port || 3000;

   async function start() {
     let config = require('./nuxt.config.js');

     //process.env.DEBUG = 'nuxt:*';

     const nuxt = new Nuxt(config);

     const builder = new Builder(nuxt);

      await builder.build().catch(error => {
        console.error(error);
        process.exit(1);
      });
  
      app.use(nuxt.render);
      app.listen(port);
    };

    start();

then fill your nodejs app like so:

    app root: your app root folder
    app url: your app url
    app startup file: app.js

note: you don't need to run the "npm run install". just open your url.