In order to check the status of the package dependencies in a web-based application powered by express framework, npm or node package manager tool provide an additional parameter to achieve it. So, this article is mainly just to show the package dependencies where the status of those dependencies will be printed in a stdout with the full informations for all the versions of packages that are installed, as well as their dependencies, in a tree-structure format. Below is the command execution :
npm list
Below is the actual execution of the above command in a newly created web-based application powered by express framework before the ‘npm install’ is executed :
user@hostname:~/nodejs/test$ npm list [email protected] /home/user/nodejs/test ├── UNMET DEPENDENCY body-parser@~1.0.0 ├── UNMET DEPENDENCY cookie-parser@~1.0.1 ├── UNMET DEPENDENCY debug@~0.7.4 ├── UNMET DEPENDENCY express@~4.0.0 ├── UNMET DEPENDENCY jade@~1.3.0 ├── UNMET DEPENDENCY morgan@~1.0.0 └── UNMET DEPENDENCY static-favicon@~1.0.0 npm ERR! missing: express@~4.0.0, required by [email protected] npm ERR! missing: static-favicon@~1.0.0, required by [email protected] npm ERR! missing: morgan@~1.0.0, required by [email protected] npm ERR! missing: cookie-parser@~1.0.1, required by [email protected] npm ERR! missing: body-parser@~1.0.0, required by [email protected] npm ERR! missing: debug@~0.7.4, required by [email protected] npm ERR! missing: jade@~1.3.0, required by [email protected] user@hostname:~/nodejs/test$
Normally, the above condition will be resolved as soon as the ‘npm install’ command is executed. The above condition itself is actually happened because there are packages or modules defined in the file named ‘package.json’ as a dependency package. It is definitely shown in the file content as follows :
{ "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" } }
The list of the package name specified in the dependencies is shown in the output of the ‘npm list’ command executed. It is because the web-based application project doesn’t have any package or modules currently needed as specified in the file named ‘package.json’. If there are files specified in the ‘dependencies’ section which doesn’t exist in the folder node_modules inside the root folder of web-based application project, the output of the ‘npm list’ command will be shown as the above output :
├── UNMET DEPENDENCY body-parser@~1.0.0 ... npm ERR! missing: body-parser@~1.0.0, required by [email protected]
It means that the dependency doesn’t met, because the file for the associated module is not exist. So, there is also another message shown below that the file is missing which is actually required by the web-based application named ‘[email protected]’ which is also described in the package.json file.
2 thoughts on “How to Check to Package Dependencies in Web-based Application powered by Express Framework using npm”