如何使用两个不同的节点版本运行两个不同的nodejs应用程序 [英] How to run two different nodejs applications with two different node version

查看:240
本文介绍了如何使用两个不同的节点版本运行两个不同的nodejs应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有两个node js应用程序,这两个应用程序不能在相同的节点版本中工作,一个应用程序仅在node4.8.3中工作,另一个应用程序仅在node10.15.1中工作.这是问题

We have two node js applications this two applications won't work in the same node version, one application only works in node4.8.3 another one application only works in node10.15.1. This is the question

因此,我们需要在具有4.8.3和10.15.1节点的同一服务器上运行两节点js应用程序

So we need to run the two-node js applications in the same server with node 4.8.3 and node 10.15.1

推荐答案

您可以使用docker同时运行多个Nodejs版本. 这可能对您有用: https://nodesource.com/blog/containerizing-node-js- docker应用程序

You can use docker to run multiple Nodejs version simultaneously. this might be useful for you: https://nodesource.com/blog/containerizing-node-js-applications-with-docker

https://blog.hasura.io/an-exhaustive-guide-to-writing-dockerfiles-for-node-js-web-apps-bbee6bd2f3c4/

互联网上还有其他有用的资源,可用于在Docker上对Node应用程序进行容器化.

There are other useful resources available on the internet on containerizing Node app on docker.

在这里Docker可能是一个更好的选择,但是如果您不想使用docker,则可以使用nvm run命令定位特定版本,而无需切换节点变量:

Docker could be a better choice here but if you don't want to use docker, you can use the nvm run command to target specific versions without switching the node variable:

nvm run 4.8.3 nodeapp1.js

对于其他节点版本:

nvm run 10.15.1 nodeapp2.js

永远使用:

forever start -c /home/ubuntu/.nvm/v10.15.3/bin/node nodeapp1.js

forever start -c /home/ubuntu/.nvm/v4.8.3/bin/node nodeapp2.js

这篇关于如何使用两个不同的节点版本运行两个不同的nodejs应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆