7

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 accomplish this task?

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? 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. Commented Oct 10, 2013 at 19:09

1 Answer 1

7

You could try the frontend-maven-plugin (via https://stackoverflow.com/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.

2
  • Thanks Jeff. This looks very promising. I'll give this a try.
    – dbrin
    Commented Nov 30, 2013 at 19:22
  • 1
    5 years later :) This plugin is awesome and highly recommended. Alternatively you should be using gradle.
    – dbrin
    Commented Oct 23, 2018 at 23:01

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.