如何使npm启动角度服务器和节点服务器 [英] How to make npm to start both angular and node servers
问题描述
是否可以使用npm启动角度默认服务器(端口:4200)和node.js(端口:8080)?
Is it possible to start both angular default server(port:4200) and node.js(port:8080) using npm?
packages.json:
"start":"ng serve && node server.js"
如果我运行 npm start ,则只有angular的服务器(4200)开始运行,而不是节点的服务器(8080).
If I run npm start, only angular's server(4200) is started running but not node's server(8080).
有没有办法使两个服务器必须使用npm同时在各自的端口上运行.
Is there a way to make both the servers has to run on their respective ports at same time using npm.
需要某人的帮助.
推荐答案
在package.json内,您可以添加
Inside of your package.json you can add
"start": "ng serve --open | nodemon node/",
请记住,它是相对于package.json位置的,因此在上面的示例中,节点是我的angular项目内的子目录.这也会为您打开一个浏览器.如果您不希望打开浏览器,只需删除--open
Keep in mind that it is relative to your package.json location , so in the above example node is a subdirectory inside my angular project. This will also open a browser for you. If you don't want the browser to open just remove the --open
完整示例
"scripts": {
"ng": "ng",
"start": "ng serve --open | nodemon node/",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
您当然可以使用gulp,正如其他答案所建议的
You can use gulp of course as the other answer suggests
这篇关于如何使npm启动角度服务器和节点服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!