Search code examples
vue.jsvuejs2nuxt.jsnginx-reverse-proxypm2

How to run nuxt dev on a production server


I'm using Nuxt 2.15.4 and I have deployed my app on a cloud-server using nginx and pm2.

I can access my website by using its domain address. Now I want to use npm run dev on another post on my server for development beside the main running website. For example https://example.com:3333 show me the dev (live) mode so that I can see changes live.

How can I do that??


Solution

  • What do you mean by "development on one of them"? Should should probably not change your code based on some handmade changes, that will not be tracked by git. How are you supposing to find bugs if you do untracked changes like this?

    And also, I'm not sure what requires that kind of workflow?

    If you have an issue on your production environment, you should fix it locally and deploy it there by knowing what are the specific differences in production.

    For your question, depending if PM2 is able to run a project with a Node.js server (I guess) it could and that you can access it with SSH (maybe you cannot), you could basically do this:

    • run a dev server on a specific port
    • connect via SSH to that specific server and make on the fly-changes
    • wait 5 hours for the page too refresh (not a bundled build so yeah, dev server will take ages to update the changes...)

    Still, it's super ugly to "make changes" like this. To understand what is buggy may be a viable use case but you could at this point, dump the production database into local or reproduce the behavior of the production locally. Anyway, I do highly not recommend this idea of running a dev server on production.