Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using NPM packages without Webpack

Tags:

node.js

npm

I am used to using NPM packages with Webpack, but I'm wondering how you're supposed to use NPM packages without Webpack. I know how to install packages. I just don't know how to use them, since you can't just import modules in plain js.

like image 957
TheCat Avatar asked Aug 16 '26 09:08

TheCat


1 Answers

Webpack compiles a bunch of javascript files and combines them into a single one for web distribution. NPM downloads javascript files through packages.

Here's some scenarios where you might use NPM without webpack

  1. You are doing Node.js server-side javascript development. There's no webpack here
  2. You are using a webpack alternative like rollup or browserify
  3. You directly do anything else with the files npm downloads. Maybe you concatenate, throw them in a Makefile or maybe you expose node_modules directly to the world and reference their full paths directly.

Most of my web and server-side development is without webpack.

like image 198
Evert Avatar answered Aug 18 '26 06:08

Evert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!