Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible: Webpack without npm?

I started to develop a new project, where frontend is on react, backend is on java play. I don't use nodejs and npm.

I try to import component that i developed and get error "ReferenceError: require is not defined". As far as i understand, the solution is to combine all react jsx files to one, using tool like webpack.

Can it be achieved using webpack, without installing npm, with the help of maven and\or IntelliJ?

like image 619
YuriR Avatar asked Sep 15 '16 19:09

YuriR


People also ask

Can you use webpack without Node?

Unfortunately, modern web development is virtually impossible without Node. It doesn't matter if you use Grunt or Gulp or Webpack as your task runner. It doesn't matter if you use Tailwind, Bulma, or Bootstrap as your CSS framework.

Is webpack part of npm?

Webpack is a static module bundler for JavaScript applications. It takes modules, whether that's a custom file that we created or something that was installed through NPM, and converts these modules to static assets.

Can I use React without npm?

While React can be used without a build pipeline, we recommend setting it up so you can be more productive. A modern build pipeline typically consists of: A package manager, such as Yarn or npm. It lets you take advantage of a vast ecosystem of third-party packages, and easily install or update them.

How do I run a webpack locally?

To run the local installation of webpack you can access its binary version as node_modules/. bin/webpack . Alternatively, if you are using npm v5. 2.0 or greater, you can run npx webpack to do it.


1 Answers

Practically speaking: no.

Webpack is a Node-based application, and to install and run it you need both Node and NPM.

Not only that, but for Webpack to do anything meaningful, it requires "loaders" that are Node modules which should be installed with NPM as well.

Lastly, when developing React apps, any external modules that your app will depend on (including React itself) should also be installed with NPM.

However, you don't need to install Node/NPM in your production environment. Webpack will generate JS-bundles that you can load into your HTML just as any regular JS script, and that part of the process doesn't require Node or NPM.

So you'll need it during development, but not in production.

like image 111
robertklep Avatar answered Oct 25 '22 00:10

robertklep