B
B
B1dloKoder2018-04-27 12:54:14
Node.js
B1dloKoder, 2018-04-27 12:54:14

How to make friends between webpack and default node modules?

By default nodes, I mean those that are provided to us immediately after installing nodejs, for example, fs, http, net, etc.
There are files that will be bundled into one using webpack, and if I want to do something like this in these files, I will get something like this
let net = require('net');

ERROR in *какой-то файл*
Module not found: Error: Can't resolve 'net' in '*какой-то путь*'
 @ *какой-то файл* 27:10-24

Answer the question

In order to leave comments, you need to log in

4 answer(s)
L
Lynn "Coffee Man", 2018-04-27
@B1dloKoder

Tell webpack that you are building an app for electron.
https://webpack.js.org/configuration/target/

M
m-haritonov, 2014-05-02
@m-haritonov

When visiting a site, the browser sends a piece of text information (called an HTTP request) over the network to the server, which, among other things, contains lines like:

GET /PAGE/ HTTP/1.0
Host: www.website.net

And the server program, when it receives such a piece of information, can either try to match the passed string ("/PAGE/") with existing files on the server (and return the contents of the found file to the browser for display), or pass this piece of information to another program (for example , PHP) and return to the browser what this program returns.

W
WhoMe, 2014-05-02
@WhoMe

The fact is that the URI does not have to be projected onto the file system, that is, www.website.net does not have to have a PAGE directory, it's just that this behavior is set by default. Google mod_rewrite

S
Sergey, 2014-05-02
Protko @Fesor

Formally, this is called CNC, and I strongly do not recommend using mod_rewrite to implement it, it is better to implement the router at the php level, and then there will be fewer problems with transferring, say, from apache to nginx. Just redirect all requests to index.php, and then let php handle it.
And start using ready-made things already, there are micro-frameworks and so on, where all this has long been implemented ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question