How to Install Express Generator in Linux Ubuntu

Posted on

This article is an article where the focus of the content is to show how to install Express Generator in Linux. The example isn this article is Linux Ubuntu 18.10. But before going into the installation process, what is Express Generator actually ?. The information about the Express Generator exist in this link. It is a link for the official website of Express JS. And above all that, there is one specific menu for explaning Express Generator. It is in the following link, where in general, Express Generator is an application generator tool,  to quickly create an application skeleton. So, the following is the step for installing Express Generator :

user@hostname:~$ npm install express-generator -g
npm WARN npm npm does not support Node.js v10.15.2
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9.
npm WARN npm You can find the latest version at https://nodejs.org/
npm WARN deprecated mkdirp@0.5.1: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR!  { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
npm ERR!   stack:
npm ERR!    'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/local/lib/node_modules' }
npm ERR! 
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR! 
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/user/.npm/_logs/2020-03-18T05_57_57_788Z-debug.log
user@hostname:~$

So, how can the installation process of express-generator end in a success ?. The answer is quite simple. According to the above output, the error is because there is a permissions issue. So, the current user which in this context, ‘user’ cannot install express-generator because that user doesn’t have any permission to execute the installation process. In order to solve the problem, just execute the following step :

1. Switch to super user, super admin or root account. The following is the command execution to achieve it :

user@hostname:~$ sudo su - 
[sudo] password for user: 
root@hostname:~#

2. After successfully switch to super user, super admin or root account, just execute the following command execution to install the express-generator :

root@hostname:~# npm install express-generator -g
npm WARN npm npm does not support Node.js v10.15.2
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can't make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9.
npm WARN npm You can find the latest version at https://nodejs.org/
npm WARN deprecated mkdirp@0.5.1: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
/usr/local/bin/express -> /usr/local/lib/node_modules/express-generator/bin/express-cli.js
+ express-generator@4.16.1
added 10 packages from 13 contributors in 1.384s
root@hostname:~# 

3. According to the above output command, the installation of Express Generator is successfully complete.

One thought on “How to Install Express Generator in Linux Ubuntu

Leave a Reply