Reputation: 788
I followed some similar posts about this questions but for me it doesn't seem right. I did npm init --yes
and now my package.json
is containning a lot of dependencies, I feel like they aren't the project dependencies but the computer dependencies.
How can I update the package.json
only with the actual project dependencies ?
[edit]
Or maybe it's my node_modules
that contains too many useless things, how can I update it to fit the current project ?
Upvotes: 0
Views: 392
Reputation: 1156
I assume that you have one project with node_modules
folder in it and you're running npm init -y
command.
If this is the case, then yes, it'll include all the packages stored in node_modules
as dependencies.
contains too many useless thing
No, those are not useless but dependencies of your actual dependencies. You might try following to get actual idea.
Create a new folder, go inside the folder, create the package.json
using npm
and then install few dependencies.
# Create an example folder.
$ mkdir example1
# Go inside the created folder.
$ cd example1
# Create package.json file using npm.
$ npm init -y
# Install few packages.
$ npm i express morgan cors mongoose
Now, go ahead and delete both package.json
and package-lock.json
files and then run the npm init -y
command again. You'll see more than 50 packages as dependencies instead of 4.
Upvotes: 1