最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Installing NodeJS via Maven - Stack Overflow

programmeradmin2浏览0评论

I see a lot of newer Maven plugins for JavaScript require NodeJS to be installed on the machine where the build takes place (both local and CI servers). For example: yeoman-maven-plugin, npm-maven-plugin, etc.

The question is: Does it make sense to check for existence of NodeJS and install it if missing via Maven as a dependency?

Bonus question: If you think this is a good idea, how would you acplish this task?

I see a lot of newer Maven plugins for JavaScript require NodeJS to be installed on the machine where the build takes place (both local and CI servers). For example: yeoman-maven-plugin, npm-maven-plugin, etc.

The question is: Does it make sense to check for existence of NodeJS and install it if missing via Maven as a dependency?

Bonus question: If you think this is a good idea, how would you acplish this task?

Share Improve this question edited Sep 24, 2013 at 15:25 dbrin asked Jul 11, 2013 at 16:49 dbrindbrin 15.7k4 gold badges58 silver badges85 bronze badges 3
  • I think that'd be a terrible idea. Wouldn't, by that logic, one expect to install Ruby or Python or any other environment if the project depends on them? If the plugin you are using is simply a wrapper for say running jsHint or jasmine tests etc., you could look for a proper self-contained plugin instead. On the other hand if it is a real node project, then why treat node as a second class citizen? – Ustaman Sangat Commented Oct 8, 2013 at 23:19
  • Most maven plugins are wrappers/adapters to native tools when they are not Java based. There are decent alternatives in many cases (WRO4J is a great example) however I keep seeing new great tools based on node and in many cases thin Maven wrappers that require Node to be already present on the system. – dbrin Commented Oct 9, 2013 at 4:58
  • What we have usually done is not try to actually install NODE but set up profiles that define where to find NODE. So for the "dev-local" profile we'd assume you have nodejs in your path. Then for the CI server, we'd assume it's at /bin/node-0.10.17/bin etc. – Ustaman Sangat Commented Oct 10, 2013 at 19:09
Add a ment  | 

1 Answer 1

Reset to default 7

You could try the frontend-maven-plugin (via https://stackoverflow./a/19600777/1024571). According the docs:

This plugin downloads/installs Node and NPM locally for your project, runs NPM install, Grunt and/or Karma

Basically it allows you to use Node as part of your build process without requiring it to be installed globally on the build machine.

发布评论

评论列表(0)

  1. 暂无评论