I am new to node.js. I know when I install a new module in node.js using npm install it gets installed but in package.json i cant find the package name in dependencies. I know i can type it out but it should appear when i install it using command prompt it should appear. Here's my package.json file. `
{
"name": "mapfeedback-test",
"version": "1.0.0",
"description": "Map feedback Javascript Test library 1.0",
"main": "client.js",
"bin": {
"mapfeedback-test": "server.js"
},
"directories": {
"doc": "docs"
},
"dependencies": {},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node server.js"
},
"repository": {
"type": "git",
"url": "ssh://[email protected]:29418/CommunityPlatform/testing/mapfeedback-test"
},
"author": "",
"license": "ISC",
"keywords": [] }
Please advice and let me know if I am wrong at something.
I use npm install
command to install all the packages but its not showing in the dependencies.
`
To add dependencies and devDependencies to a package. json file from the command line, you can install them in the root directory of your package using the --save-prod flag for dependencies (the default behavior of npm install ) or the --save-dev flag for devDependencies.
If you want to see the entire dependency tree, use the --all argument: npm ls --all.
NPM installs devDependencies within the package. json file. The 'npm install' command should add all the dependencies and devDependencies automatically during installation. If you need to add specific devDependencies to your project, you can use this command- 'npm install --save-dev'.
Quickest way to fix this would be to run:
npm install <dependencies listed here> --save
And that should add them to the package.json
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With