Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is a Hello World angular app 300 megabytes?

I'm an experienced Java/Tomcat developer, experimenting with AngularJS for the first time. I don't know much about npm, node, yeoman, bower, etc. I followed a tutorial to download these tools and create a new AngularJS project.

I don't remember all the steps, but the part about creating the Angular project was this:

npm install generator-angular
yo angular

The resulting empty project is 307.9 megabytes.

By comparison, creating a new empty Tomcat application from IntelliJ is 45 kilobytes.

Am I doing something wrong? If not, does it seem reasonable that the 'lightweight' Angular project is thousands of times larger?

like image 281
Jesse Barnum Avatar asked Oct 17 '22 22:10

Jesse Barnum


1 Answers

This is because the NPM package manager downloads the necessary dependencies to the node_module folder. AngularJS is very different from 2+. For example, from version 2 onwards, they all use TypeScript, and to be able to load and compile everything you need Angular to work, it requires many libraries. However, if you use NPM, you can use the command npm run-build which allows you to compile your view, generating an output folder called "output" or similar. In this way, those files are the ones that you should upload to your server, or give it importance.

like image 73
nicobuzzi Avatar answered Oct 21 '22 05:10

nicobuzzi