Unable to change server PORT
See original GitHub issueEnvironment
Nuxt CLI v3.0.0-27436017.7b6252a 11:33:31 RootDir: C:\devSandbox-Tom\DevFork-Tom\MAS-Auth\mas-auth-web3 11:33:34 Nuxt project info: 11:33:34
- Operating System:
Windows_NT
- Node Version:
v16.13.1
- Nuxt Version:
3.0.0-27436017.7b6252a
- Package Manager:
npm@8.5.1
- Bundler:
Vite
- User Config:
typescript
,server
- Runtime Modules:
-
- Build Modules:
-
Reproduction
I have tried several different coding methods as start-up scripts and nothing has worked. I have set .env PORT=4000
nuxt.config.ts import { defineNuxtConfig } from “nuxt3”;
// https://v3.nuxtjs.org/docs/directory-structure/nuxt.config export default defineNuxtConfig({ typescript: { shim: false, },
server: { port: process.env.PORT || 4000, }, });
Describe the bug
Common methods for setting the port for Nuxt2 do not work in Nuxt3. Nuxt3 will only run on port:3000
Additional context
No response
Logs
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:5 (2 by maintainers)
Top GitHub Comments
I found it!!! I was looking in all the wrong places.
http://v3.nuxtjs.org/getting-started/commands options.server from nuxt.config is not supported. You can use --port, --host, --https, --ssl-cert and --ssl-key instead.
"scripts": { "dev": "nuxi dev --port 4000",
That doesn’t work. I get the error that PORT is not a recognized command. I also modified the dev to
"scripts": { "dev": "PORT=4000 nuxi dev",
same error.I also found this example for a node server
SET PORT=8080 && node server.js
but I have tried this in several different combinations of things and still doesn’t work. No error, but the server doesn’t start.<< or load it into your shell in some other way >> I have looked and don’t see any way to do this. I can check for an open or active port, but I can’t set one.
If there is no reasonable easy viable way to set the PORT during development? I would consider that a bug. Just saying.