Nuxt.js: [Question] How to configure port where nuxt.js is running?

Created on 19 Jan 2017  ·  4Comments  ·  Source: nuxt/nuxt.js

How to configure port where nuxt.js is running in production mode?

This question is available on Nuxt.js community (#c125)
question

Most helpful comment

Hi, you can configure the PORT with 2 different ways:

  • Via a env variables
"scripts": {
  "dev": "PORT=3333 nuxt"
}
  • Via a nuxt config in the package.json:
"config": {
  "nuxt": {
    "port": "3333"
  }
},
"scripts": {
  "dev": "nuxt"
}

All 4 comments

Hi, you can configure the PORT with 2 different ways:

  • Via a env variables
"scripts": {
  "dev": "PORT=3333 nuxt"
}
  • Via a nuxt config in the package.json:
"config": {
  "nuxt": {
    "port": "3333"
  }
},
"scripts": {
  "dev": "nuxt"
}

Super! Thank you @alexchopin

@alexchopin I had tried those ways you say above, but It can worked in linux & mac,not work in windows. would you give some ideas?

env:

yarn run v1.2.1
warning You are using Node "9.4.0" which is not supported and may encounter bugs or unexpected behavior. Yarn supports the following semver range: "^4.8.0 || ^5.7.0 || ^6.2.2 || ^8.0.0"
$ HOST=0.0.0.0 PORT=8082 nuxt
'HOST' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
$ npm run dev

> [email protected] dev C:\Users\classlfz\Documents\github\doxhub-official-website
> HOST=0.0.0.0 PORT=8082 nuxt

'HOST' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `HOST=0.0.0.0 PORT=8082 nuxt`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\classlfz\AppData\Roaming\npm-cache\_logs\2018-01-29T09_36_04_650Z-debug.log

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

shyamchandranmec picture shyamchandranmec  ·  3Comments

bimohxh picture bimohxh  ·  3Comments

mattdharmon picture mattdharmon  ·  3Comments

danieloprado picture danieloprado  ·  3Comments

maicong picture maicong  ·  3Comments