10 things I wish I knew about Node when I started

Everyone comes to Node from different angles. Some back-end developers decide to dive into JavaScript. Sometimes a front-end developer will choose Node as their first back-end language. Regardless of your path, getting started with Node can sometimes be a challenge. One of the big reasons for this is the context switch. The Node ecosystem is as different as any other.

In this article, I have listed ten things I wish I knew when I got started with Node. This is in no way an exhaustive list, nor is it a definitive “getting started” guide. There are resources available if you need that kind of direction. This is a list of things I wish I knew when I first started learning about Node.js. I hope this list fills in some gaps and saves you some time.

1 - Ignore your node_modules folder

Everyone has done it once. You use git add * and wind up committing your node_modules folder. Major bummer. But instead of leaving post-it notes for yourself everywhere, you can use your .gitignore file to ensure that the node_modules folder is always ignored automatically.

2 - nodemon

Node is great. Using Ctrl + C to stop your Node process and then start it again with every file change is not cool. Nodemon restarts your Node application every time you change a file. Once I started using it, I wondered how I lived so long without it.

More Info:

https://github.com/remy/nodemon

3 - npm ls

When your npm install command completes, you see a nice visualization of all the modules you just installed. But once you run another command or close your terminal window, that list is gone. There have been times when I thought: “hmmmm… it sure would be nice to see that list again”. The command npm ls will show that list. This is super helpful when you want to view installed which modules. The highlight is a including a hierarchical relationship.

More Info:

https://docs.npmjs.com/cli/ls

4 - NPM Scripts

There is more power to npm than meets the eye. Npm scripts allow you to execute code at key points in the npm lifecycle. For example, you can run a script before package installation, or after. There are other hooks and they are useful.

More Info:

http://www.nodejsconnect.com/blog/articles/getting-started-npm-scripts

5 - Node Inspector

At first I thought it was cool that I could use console.log() statements to debug my node applications. After about 20 minutes, I realized that it was not cool. node-inspector allows you to debug your Node application just as you would other languages.

More Info:

https://github.com/node-inspector/node-inspector

https://www.youtube.com/watch?v=F3LgtcfF2FM

6 - Installing Node via a package manager

Gonig to https://nodejs.org and downloading the installer for your OS is simple, and that is great. Using a package manager to install Node is better. There are two big reasons for this: When you use a package manager, you have access to the latest version. Also, you have the ability to upgrade Node. If you are a Mac user, Homebrew is probably the most popular. If you are a Windows user, scoop is well known and well liked.

More Info:

https://nodejs.org/en/download/package-manager/

http://brew.sh/

http://scoop.sh/

7 - The process object

For front-end web developers, the window object is a global object that all major browsers support. In the Node.js, there is no window object. There is the process object. There is power here. For example, access the arguments passed to node when the running program started. There is a lot more where that came from and the documentation is solid.

More Info:

https://nodejs.org/api/process.html

8 - JS Linting and Hinting

Ok, this isn't specific to Node, but it's worth mentioning. Using a JS linting tool is a good idea. You will catch syntax and grammar errors sooner. It also forces to you pay closer attention to your code.

More Info:

https://www.sitepoint.com/comparison-javascript-linting-tools/

9 - Openshift

There are plenty of options for Node hosting. For example, services like Heroku and AWS are popular. Each has its pros and cons. I have found Openshift to be helpful. Getting started is easy and their documentation is solid. I found Openshift to offer a great balance of features and ease of use. And that was their free tier.

More Info:

https://www.openshift.com/

https://developers.openshift.com/languages/nodejs/getting-started.html

10 - The latest version of Node supports ECMAScript 2015

This would not have been applicable in 2012, but the concept is one I wish I had paid more attention to. One of the great things about Node is that there is no need to wait for browsers to catch up. If you have the latest version of Node, then you have the most up-to-date support for ECMAScript 2015.

More Info:

http://node.green/

http://www.ecma-international.org/ecma-262/6.0/

http://es6-features.org/

Author

Kevin Chisholm

http://blog.kevinchisholm.com

Share This