How to Solve npm Error Message : npm ERR! missing

Posted on

This is specifically written for solving the problem specified in the title of this article. It is how to solve an error message : npm ERR! missing. It is an error message when the command ‘npm list’ is executed. It is referring to the article shown with the title of ‘How to Check to Package Dependencies in Web-based Application powered by Express Framework using npm’ in this link. The error itself is happened because there are several files defined in the file named package.json inside the root folder of the web-based application project and those files don’t exist in the folder node_modules. The output specified as part of the error is shown below :

user@hostname:~/nodejs/test$ npm list
application-name@0.0.1 /home/user/nodejs/test
├── UNMET DEPENDENCY body-parser@~1.0.0
npm ERR! missing: body-parser@~1.0.0, required by application-name@0.0.1

So, the main solution is to add the missing file specified in the above output command. The purpose of the file representing the package or module named body-parser with the version of 1.0.0 is to met the dependency specified in the package.json file. Below is the declaration of the dependency for the associated package or module named ‘body-parser’ with the version of 1.0.0 :

  "name": "application-name",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "nodejs ./bin/www"
  "dependencies": {
    "express": "~4.0.0",
    "static-favicon": "~1.0.0",
    "morgan": "~1.0.0",
    "cookie-parser": "~1.0.1",
    "body-parser": "~1.0.0",
    "debug": "~0.7.4",
    "jade": "~1.3.0"

As shown below, the folder named ‘node_modules’ is not exist at the first place because there haven’t any action taken to solve the dependency problem using ‘npm’ command tool :

user@hostname:~/nodejs/test$ ls
app.js  bin  package.json  public  routes  views

So, the command to fulfill the solution or to solve the problem related to the package or module dependency is shown below :

npm install package-or-module-name

Below is the actual execution of the above command :

user@hostname:~/nodejs/test$ npm install body-parser
application-name@0.0.1 /home/user/nodejs/test
└─┬ body-parser@1.0.2 
  ├── qs@0.6.6 
  ├─┬ raw-body@1.1.7 
  │ ├── bytes@1.0.0 
  │ └── string_decoder@0.10.31 
  └─┬ type-is@1.1.0 
    └── mime@1.2.11 


Check the content of the root folder of web-based application project again :

user@hostname:~/nodejs/test$ ls
app.js  bin  node_modules  package.json  public  routes  views
user@hostname:~/nodejs/test$ cd node_modules/
user@hostname:~/nodejs/test/node_modules$ ls
body-parser  bytes  mime  qs  raw-body  string_decoder  type-is

As it can be seen in the above output, the package or module named ‘body-parser’ with its fellow package or module dependencies have already been stored inside the folder named ‘node_modules’. The correct solution can be achieved by the above command. It is effective if the packages or modules are not that much, let’s say just one or two packages or modules. But the more packages or modules which becoming the problem of unmet dependencies, it can be solved by one single command of ‘npm install’. It will automatically runs into all files specified in the ‘dependencies’ section declared in the file named package.json for further downloading and storing all of those packages or modules in the folder named ‘node_modules’ where it is specifically intended for this purpose.

Leave a Reply