Delivering great software is the goal. Delivering great software fast? Now, that is the ultimate goal. Thus, a few hacks and shortcuts can really come in handy.
For those who rely heavily on Node.js on coding tasks and wants to breeze through setting up and to immediately get coding, here’s a guide on how we set up a Node.js development environment for a particular project:
What is Node.js?
If you’re new to web development, it can be a bit confusing as to what exactly node.js is and to what you should do with it, and there’s a lot of information out there…most of which seems to be tailored towards genius-level developers.
To wrap it up, we’re going to spin up a quick web server in node.js just to show you how easy it is.
Install NPM and Node.js
Of course, to get things started you need to install npm, and Node.js. You can easily do that by downloading them from here.
Create a project folder
Navigate to your folder by using your favorite terminal. Proceed to creating a package.json file in that folder. This will save all the libraries you use. Using the terminal, run the command $ npm init . Write a few details about your project.
The web framework
This should be project based, but we recommend Express.js as it is the most mature and widely used framework for Node.js. From the Terminal, navigate to the folder where you will build your project, and run $ npm install express –save.
The testing framework
To deliver robust code, you need to write tests. Node.js has a lot of testing frameworks available, but Mocha.js is by far the most used and proven test framework out there. To install, run $ npm install –save-dev mocha.Here, we also need to mention the assertion library. It really makes life easier. We recommend Chai.js, as it exposes all interfaces of asset. Just run $ npm install –save-dev chai in your terminal to install.
We’ve chosen Visual Studio Code over the more widely preferred Sublime Text, as it has a native support for Node.js debugging. Also, easier to adopt for beginner- developers. You can get this free piece of software from here.
– Eslint-node: $ npm install –save-dev eslint-plugin-node
– Eslint-mocha: $ npm install –save-dev eslint-plugin-mocha
The coding standards:
Install the ESLint plugin in VS Code
Go into the VS Code app and navigate to its Extensions page. Search after “eslint”, and install the first result from the list. Restart VS Code.
Now you’re all set, start coding and enjoy!