The plugins can be configured in the
Gruntfile.coffee files. The
Gruntfile.coffee is only available if you are using CoffeeScript. The same two files are also used to define the tasks which you want to automate. Either of these files is also commonly known as Gruntfile. Note that your plugins still need to be listed in the
package.json file preferably as devDependencies. Just keep in mind that, when another Node package depends on yours, then it will automatically install all runtime dependencies of your package, but not the devDependencies as they are used during the development of the application, and will not be required in the deployment together with the app.
Again, you will need a specific file for it – a
gulpfile.js in your project root that contains your tasks. Still, note that Gulp prioritizes code over configuration which makes certain tasks very simple and efficient and also reduces wasted time during the actual creation of a build.
Gulp users can take advantage of more than 3600 plugins and with 850 000 weekly downloads it has become one of the top tools for developers in NPM.
While talking about Bower, we have to mention NPM as both have a lot of similarities. In a sense Bower and a browser have a similar relation as NPM has to Node.js. They are both dependency management tools. However, NPM is used for installing Node.js modules while Bower is used for managing frontend components like HTML, CSS, JS, etc and you will need NPM in order to install Bower.
Then, similarly, as you have done with NPM, you will need to execute
bower init on your terminal to create a new
bower.json configuration file (the equivalent of
package.json for NPM).
However, while frequently mentioned in the community, Bower is now considered morally old and is still in use due to is heavy usage in legacy apps. This is more evident by the note from the author of Bower on the website’s home page and similar note in the NPM package page:
node_modules folder given a
yarn.lock file. However, this is true only as long as everyone on your team is using the same version of Yarn as the position of packages in node_modules is computed internally in Yarn. This means that using different versions may very well have a non-deterministic outcome due to small differences in Yarn.
Furthermore, Yarn has great caching capabilities, selective version resolutions, auto-merging of lockfiles and Workspaces. The latter of which lets teams automatically combine all of the dependencies from multiple
package.json files and install them at once. Not only that, but it can also create symlinks between workspaces that depend on each other which is even more convenient for large-scale projects. Considering all of the upsides, it doesn’t come as a surprise that since v. 1.0.0, Yarn also comes pre-installed on major continuous integration platforms such as CircleCI, Travis CI, and AppVeyor. As of 1.7.0, Yarn is also able to import its dependency tree from NPM’s
package-lock.json natively, without any external tools.
PM2 is a process monitoring module for Node.js applications. It allows you to keep applications alive forever, restart them without downtime and create common DevOps tasks. We already did a more detailed review of PM2 in our How to use PM2 tutorial. it includes commands and the further development of an external dashboard with metrics, again a creation of the PM2 Team.
Are tools always necessary?
Absolutely not. For some projects, the extra abstraction added by the tools will not only bloat the actual project but also slow down the development process. Part of a developer’s work is to find the optimal way of doing the task at hand, and while useful, these developer tools are not always needed in order to achieve the optimal build. There are great projects with a complex structure that are built only with the help of the plain NPM.
Do you want to learn more?
While we do have more tools in the pipeline being prepared for deployment on a binary level on our Shared Hosting Environment, we do want to hear your feedback on the information we provide. Do you want to learn more about Grunt and Gulp? Are you interested in finding out more about lockfiles, useful plugins, and commands for these tools? Just write a comment below, about what you want to see next, and we will be sure to reply or incorporate a more detailed answer in one of our next blog posts or tutorials.