Hello, I just learned about npm and I'll like to get more clarification on usage of npm in web development(especially frontend development). From what I learned, npm installs packages to a local directory while cdn gives access to packages on a server. So this is where I get confused, if, for instance, I host my git repository on netlify, how would my site access the packages since I didn't upload npm modules?
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (4)
When web pages load their content is downloaded to make it work. There are two ways to get the content. CDN or via a NPM package.
The package.json file lists all npm installed packages. When compiled, that content exists in your distribution folder. At load time that content is used.
CDNs deliver the same content but all that content exists on their servers.
Thank you. I'm learning about bundling already.
Hey! Good question. I see your confusion and itβs totally fine!
Npm modules do install stuff locally but often the install instructions each module should clear this up.
Generally speaking, when you build your website/web app for hosting on a website, the building tool (webpack, gulp, etc) will do all that work of getting the modules (or the subset youre using) into the package you upload (sometimes called compiling or bundling)
Do keep reading about this though - there are quite a few concepts here that youβll definitely need to get your head around to continue down this path - and well worth learning :)
Thank you. I've started learning about bundling using webpack.