dependencies not showing in package.json in Node.js

Quickest way to fix this would be to run:

npm install <dependencies listed here> --save

And that should add them to the package.json

Update:

Couple of extra commands for future viewers of the OP:

To add the package to your devDependencies instead of dependencies

npm install <dependencies listed here> --save-dev


There are also some handy shortcuts for both commands:

dependencies:

  • npm i <dependencies listed here> -S

dev-dependencies:

  • npm i <dependencies listed here> -D

The npm documentation is here.

And if you are a fan of shortcuts and npm configuration here is a useful link to find even more.


For npm packages to appear in package.json automatically you need to use this command:

 npm install packagename --save

Use following command

npm install <pkg-name> --save

--save instructs npm to include package inside dependencies of package.json