How to change a port number in Vue App
In this tutorial, we are going to learn how to change a default port number in vue app which is created using the vue cli.
Changing port number
-
Open the vue app in your favorite code editor.
-
Create a new file called
vue.config.js
in your root directory. -
Add the following code, by replacing it with your port number.
module.exports = {
devServer: {
port: 3454 }
}
- Now, run the app using
npm run serve
command, your port number is successfully changed.
DONE Compiled successfully in 2114ms
App running at:
- Local: http://localhost:3454/
- Network: http://192.168.43.18:3454/
Note that the development build is not optimized.
To create a production build, run npm run build.
If you want to change the port number temporarily, you can add a --port
option to npm run serve
command.
Example:
npm run serve -- --port 2345
You can also learn about, how to change a port number in React.