简体   繁体   English

当我运行 npm dev 时,它同时打开不包含我的项目的 localhost 3000

[英]when i run npm dev which is concurrently opens localhost 3000 which does not contain my project

"scripts": { "start": "react-scripts start", "server": "nodemon server ", "client": "npm start --prefix client ", "dev": "npx concurrently "npm run server" "npm run client"" "scripts": { "start": "react-scripts start", "server": "nodemon server", "client": "npm start --prefix client", "dev": "npx concurrently "npm run server" “npm 运行客户端”“

This is the code on my server package json when I npm run dev it opens localhost 3000 which should have my frontend application but instead opens a new react app local host 3000这是我的服务器 package json 上的代码,当我 npm 运行 dev 它打开 localhost 3000 应该有我的前端应用程序但是打开一个新的反应应用程序本地主机 3000

If I log into my frontend and run,it runs successfully on local host 3000 or sometimes claims that local host 3000 is occupied and changes the port number to local host 3001如果我登录到我的前端并运行,它在本地主机 3000 上成功运行,或者有时声称本地主机 3000 已被占用并将端口号更改为本地主机 3001

I need For the npm run dev to open both client and server concurrently therefore opening the correct localhost 3000 which contains project interface我需要 npm run dev 同时打开客户端和服务器,因此打开包含项目接口的正确本地主机 3000

I believe you are trying to run both processes on the same PORT.Well it is not convenient to run two process on a single port concurrently you need to specify two distinct PORTs for each process.我相信您正在尝试在同一个端口上运行两个进程。好吧,在一个端口上同时运行两个进程并不方便,您需要为每个进程指定两个不同的端口。

Refer: Can two applications listen to the same port?参考: 两个应用程序可以监听同一个端口吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么我的网络应用程序可以在localhost(npm run dev)上正常运行,但是在部署到heroku时看起来像垃圾? - Why does my web-app work fine on localhost (npm run dev) but look like trash when deployed to heroku? 我在节点后端运行 npm run dev 时出现问题 - Problem when i run npm run dev in my node backend 当我运行“ npm start”时正在运行哪些js文件? - Which are the js files that are being run when I run “npm start”? 刚开始新项目,当我运行 npm run dev 时,它会在终端中引发错误 - Just started new project and when I run npm run dev it throws an error in the terminal 端口 3000 已在使用中 每次我重新启动 npm run dev 时都会出错 - Port 3000 is already in use Error every time I restart npm run dev 为什么 webpack 在运行 npm 运行开发时会出错 - why does webpack gives error when run npm run dev npm start 什么都不做 / localhost:3000 连接被拒绝 - npm start does nothing / localhost:3000 connection refused npm dev:start 不运行 - npm dev:start does not run NestJs 项目不显示在“npm run start”或“npm run start:dev”之前使用“tsc”命令的更新 - NestJs project does not show the updates with "tsc" command before "npm run start" or "npm run start:dev" 当我运行 ```npm run dev`` 时,CSS 文件会发生变化 - CSS files changes when I run ```npm run dev``
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM