Nodejs because so many files

Asked

Viewed 110 times

4

Good afternoon, everyone,

I’m starting a short time with Nodejs a little project in VUEJS, and I saw that when I give the command

NPM INSTALL

it creates about 20,000 files, my application gets to get 100mb without having almost any dependency...

What’s so much folder and file for?

1 answer

3


The packages you install with npm install are programs necessary to the dependencies you referred to in packacge.json. They are there because they are needed in some part of programs/packages that you will use.

For example, the webpack alone has 22 dependencies, and is an essential part to compile the code to use.

You can always remove packages that you no longer need, but there is starting, to have the features you need and for the code to be packaged and go (as light as possible) to the client/user, then these dependencies are needed.

These programs go to the folder node_modules that you should ignore with a line on .gitignore because you should not "commit" those folders or copy them. If you take into account that each package has its dependencies, which have its dependencies... it is a bit of a vicious circle. Hence 100mb in this case.

Try to keep only the packages you need, but of course, there’s npm many useful and interesting things... it is easier to accumulate than to clean.

  • I get it, these dependencies are like: A Visual Studio uses its own dependencies to compile projects, but in the case of Nodejs, we can see in the folder all its dependency files, would that be about right? Thank you!

  • 1

    @Exact Jackson. Remember to ignore the folder and subfolders in the .gitignore, to avoid having ballast in Github for example.

  • What would Gitignore be? I couldn’t find this folder. Thank you!

  • 1

    @Jackson the .gitignore is a file with that name (no extension) I put. It is to tell Github which files to ignore to avoid checking in and sending to Github extra files. Take a look here: https://github.com/github/gitignore/blob/master/Node.gitignore

  • 1

    Hmm understood! It was clear. Thank you! :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.