如何部署一个node.js应用程序与maven? [英] How to deploy a node.js app with maven?

查看:670
本文介绍了如何部署一个node.js应用程序与maven?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们的大部分团队由java开发人员组成,因此整个构建/部署/依赖关系管理系统构建在maven之上。我们使用CI,所以每个构建过程运行单元测试(前端的karma和phantomJS,后端的茉莉花节点)。我已经设法为此目的配置一个karma maven插件。

Most of our team consists of java developers and therefore the whole build / deployment / dependency management system is built on top of maven. We use CI so every build process runs unit test (w. karma and phantomJS for the frontend, and jasmine-node for the backend). I've managed to configure a karma maven plugin for this purpose.

这不解决从package.json下载node.js依赖的问题。我需要在现有环境中部署我的node.js / express应用程序,因此完美的情况是:

This does not solve the issue of downloading node.js dependencies from package.json on build. I need to deploy my node.js / express app in existing environment, so the perfect scenario would be:


  1. pull (从maven build自动完成)

  2. npm install >
  3. 运行测试

  1. pull from the repo (done automatically with maven build)
  2. npm install (that is - downloading dependencies from node package registry)
  3. running tests


$ b $ p我试图找到一个nodejs包为maven,一个node.js开发人员当我选择正确的工具,我不觉得很自信,因为我不能区分一个坏的maven插件从一个体面的。

I was trying to find a nodejs package for maven, but to be honest - as a node.js developer I do not feel very confident when it comes to choosing the right tools, since I'm not able to distinguish a bad maven plugin from a decent one.

也许使用shell插件并从终端调用 npm install 是更好的选择?

Maybe using a shell plugin and invoking npm install from the terminal is a better choice?

推荐答案

您有两种选择:

  • https://github.com/eirslett/frontend-maven-plugin to let maven download your npm modules from your package.json and let it automagically install node and npm all along

https://github.com/mulesoft/npm-maven-plugin 让maven下载您在pom.xml中指定的npm软件包

https://github.com/mulesoft/npm-maven-plugin to let maven download your npm packages that you have specified in the pom.xml

作为一个复杂的解决方案,虽然仍然可行,你可以像你自己提到的,使用像maven-antrun-使用maven执行npm。

As a hacky solution, though still feasible you could as you've mentioned yourself, use something like maven-antrun-plugin to actually execute npm with maven.

所有方法都有其优点和缺点,但是frontend-maven-plugin似乎是最常用的方法 - 可以从互联网任意包下载,而hacky解决方案也应该工作,当你的ci服务器没有连接到互联网(除了代理中央maven仓库)

All approaches have their pros and cons, but frontend-maven-plugin seems to be the most often used approach - but it assumes that your ci server can download from the internet arbitrary packages, whereas the "hacky" solution should also work, when your ci server has no connection to the internet at all (besides proxying the central maven repo)

这篇关于如何部署一个node.js应用程序与maven?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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