Many Node.js code snippets found online make use of the popular Express library, which greatly simplifies the process of writing your own web server, especially if you’re just getting started with Node.js. However, it requires the installation of the express module, which can be done using npm. Failure to do so may result in the following error.
‘Error: Cannot Find Module ‘express’‘
You can install Express globally by typing npm install -g express at your command prompt/terminal. You can also install Express in your project’s directory only by typing npm install express in the root of the Node.js project’s director. That way, you’ll have more control over which version you use for each project. For example, you may want to use an earlier version of Express for an older Node.js program that hasn’t yet been updated to work with the latest version.
To do that, you can type npm install express@3, if you want to install the latest version of Express 3 (not the latest version of Express, but the latest version of Express 3).