How to add dependency to package.json later

Just do: npm i name_of_package -S or the long version: npm install package_name --save

If you need to save it as a dev dependency, use the -D flag


You can run the same command again, specifying --save flag and it will be automatically included in package.json. The only problem is that the version of the package can be updated to newer version, so you may specify the specific version of your app: npm i --save [email protected].

Alternatively you can modify package.json yourself to include the dependency:

"dependencies": {
    "module": "*"
} 

Tags:

Node.Js