Why can webpack use node.js 's built-in module directly through require ('path')

this question may seem funny, and I often use webpack, to use node.js modules, so I don"t find it strange because I followed the tutorials before.

but now think about why webpack can use node.js "s built-in modules directly through require ("path").

it feels like webpack started a service through node when it was packaged. Or, when using webpack, the project itself is already a node project?

I hope you can answer my questions and questions ~ pen refill

Mar.28,2021

  • js is an interpreted language that cannot be run directly and requires a runtime environment.
  • the common running environments are web browsers, back-end servers (nodejs environment), etc.
  • The js in
  • webpack runs not in the browser, but in the back-end environment, which is the nodejs environment.
  • is equivalent to running in a nodejs environment. Webpack, can of course use the node built-in module.

I have the same question, waiting for the master to answer.


webpack this project depends on node.js development.
your project won't run at all if you don't install node.js .
you can also use node.js to customize your own webpack

npm install webpack is downloaded from node


just like when you generate a template for webpack with vue cli, npm run dev, is actually a npm script command configured in pakcage.json, and the real command is the webpack of node startup development environment

.
Menu