'Nuxt3 Vite server port

I need to config server port for Nuxt3. I try to do it so:

nuxt.config.ts

import { defineNuxtConfig } from 'nuxt3'

export default defineNuxtConfig(
  vite: {
    server: {
      port: 5000,
    },
  },
})

But it doesn't work. How to set server port in Nuxt3?



Solution 1:[1]

As told here, this is currently not supported.

Change it like this

{
  "scripts": {
    "build": "nuxt build",
    "dev": "nuxt dev --port=5678", // here
    "generate": "nuxt generate",
    "preview": "nuxt preview"
  },
  "devDependencies": {
    "nuxt": "3.0.0-rc.1"
  }
}

Here is how to change the port for production: https://github.com/nuxt/framework/discussions/1884#discussioncomment-1631668

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1