how to run vue js project on different port
To run a Vue.js project on a different port, you can follow these steps:
- Open the terminal or command prompt in the root directory of your Vue.js project.
- Locate the
package.json
file in your project's root directory. - Open the
package.json
file in a text editor. - Find the
"scripts"
section within thepackage.json
file. - Look for the
"serve"
script, which is responsible for running the development server. - By default, the
"serve"
script looks something like this:"serve": "vue-cli-service serve"
. - To specify a different port, modify the
"serve"
script to include the--port
flag followed by the desired port number. For example:"serve": "vue-cli-service serve --port 8080"
. - Save the changes to the
package.json
file. - In the terminal or command prompt, run the following command to start the development server with the updated port configuration:
npm run serve
oryarn serve
.
Once the development server starts running on the specified port, you should be able to access your Vue.js project by visiting http://localhost:<port>
in your web browser, where <port>
is the number you specified in the "serve"
script.
This allows you to run your Vue.js project on a different port than the default port (usually 8080) and avoid port conflicts with other running applications on your local machine.