I am exploring AngularJS tutorial project and found it has
node_modules directory inside, which size if 60 megabytes.
I tried to delete this directory and project still works. I suspect it somehow relates with
node.js and it's
npm but how? Suppose I need to run my project on some conventional web server (not node.js), then how to know, which files/directories are unneeded?
node_modules directory is only for build tools.
package.json file in the app root defines what libraries will be installed into
node_modules when you run
When you deploy your app, you only distribute the resulting build, not any of the source files or build tools.
It is of course possible to write an AngularJS app without building anything.
edit from comments: When you dive into Angular more, there are more advanced techniques of using libraries installed by npm even in the client app, you then selectively choose the ones you need, not the whole 50MB+ thing. I'd recommend staying with the basic approaches until you get a good grasp on them though.
NPM is the node package manager, which installs packages locally into a project, specifically, into the
node_modules folder. From there the package code can be included into a project, yes, can is the important word there.
The browser has no way to include modules in code (yet), so you need to use a library that can expose node's commonJS style modules. Browserify and Webpack are two popular methods of doing so.
Angular complicates this by introducing its own module system, which more closely resembles AMD-style modules. There are ways around this, so that you can use node-style modules, maybe your project uses those.
npm for managing dependencies is a great idea, its a fantastic package manager. It is likely in your case though that the project is only built using
node and that the
node_modules folder contains dependencies only related to the build.
©2020 All rights reserved.