Skip to content
the poor coder

live vue js port number

Poor Man
Published
Reading time
1 min read
On this page

Live Vue JS Port Number#

In order to run a Vue JS application, a development server is required. This server runs on a specific port number which needs to be specified in the configuration of the application. The default port number for a Vue JS application is 8080.

However, if this port number is already in use on your machine, you will need to specify a different port number. There are a few ways to do this:

Method 1: Specify Port Number in Command Line#

When running the Vue JS development server, you can specify the port number in the command line using the following syntax:

Bash
$ npm run serve -- --port 3000

This will start the server on port number 3000 instead of the default port number 8080.

Method 2: Specify Port Number in Configuration File#

You can also specify the port number in the configuration file of the Vue JS application. This file is usually named vue.config.js and is located in the root directory of the project.

To specify the port number, add the following code to the configuration file:

JavaScript
module.exports = {
  devServer: {
    port: 3000
  }
}

This will start the server on port number 3000.

It is important to note that if you use this method, you will need to restart the development server for the changes to take effect.

Method 3: Use Environmental Variables#

Another way to specify the port number is to use environmental variables. This method is useful if you want to specify the port number dynamically based on the environment.

To use this method, modify the vue.config.js file to include the following code:

JavaScript
module.exports = {
  devServer: {
    port: process.env.PORT || 8080
  }
}

This code specifies that the port number should be taken from the PORT environmental variable, but if this variable is not set, it should default to port number 8080.

Using one of these methods, you can easily specify the port number for your Vue JS application and run it on a different port number if necessary.

Keep going

2023

how to sort an array

How to Sort an Array If you have an array and you want to order its elements in a specific way, you need to use a sorting algorithm. There are several sorting algorithms available, but two of the most commonly used are…

javascript2 min read
2023

jquery mobile or desktop

jQuery Mobile or Desktop? As a web developer, I have had some experience with both jQuery Mobile and jQuery Desktop. Both frameworks have their pros and cons, and which one to use really depends on the specific project…

javascript1 min read
2023

node.js folder structure

Node.js Folder Structure If you are new to Node.js, it can be daunting to create a folder structure that will work for your project. The structure you choose will depend on the size and complexity of your project. Here…

javascript1 min read
ESC