Home  >  Article  >  Web Front-end  >  How to change the port number in react?

How to change the port number in react?

青灯夜游
青灯夜游Original
2020-11-26 13:55:383875browse

How to modify the port number in react: 1. Open the "node_modules"-"react-scripts"-"scripts" folder in sequence, find and open the start.js file; 2. Search in the start.js file And modify the value of the "DEFAULT_PORT" item.

How to change the port number in react?

The operating environment of this tutorial: windows7 system, react16 version. This method is suitable for all brands of computers.

Problem

We often encounter this situation when using React, the 3000 port number is occupied. Sometimes port 3000 can be turned off, but more often, when we need to open multiple projects, we must open multiple ports. At this time, you need to modify the default port number.

Solution: Modify the default port number

Specific Method

  • Step 1: Find the start.js file

The location of this file is: under the node_modules folder-> under the react-scripts folder -> Under the scripts folder-> Under start.js

node_modules:

How to change the port number in react?

##start.js file:

How to change the port number in react?

Modify at line 51, the entire file port number only appears once

How to change the port number in react?

The running result after modification

For more programming-related knowledge, please visit:

Introduction to Programming! !

The above is the detailed content of How to change the port number in react?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn