I make authorization \ registration, and when connecting along the route
const regpath = path.join (__ dirname, 'public / registration.html');
app.use ('/ reg', express.static (REGPATH));
Error Http: // Localhost: 3000 / js / registry.js net :: er_aborted 404 (not found)
.
File Structure and Sublines Such is:
I can not understand where it made a mistake, the route in the route, Toli in connection of the file
Answer 1, Authority 100%
404 error
means – no file for this path (file not found)
Node does not give it, therefore you must share it (Share, specify a public directory), for example: [Project Folder] / Public
, and already in a public folder (/ public
) Put the public folder – / js
. Read here
It turns out: [Project Folder] /Public/JS/File.js
Add to node before routing:
app.use (express.static (__ dirname + '/ public'));
If the HTML is written so:
& lt; script src = "js / file.js" & gt; & lt; / script & gt;
… (+ in node – as above) MOT: Your file will be requested on the next way: [Project Folder] /Public/JS/File.js
, and not [Folder of .html] /js/file.js
In general, I would read in your place as Folduring on Node is done humanly.
Visual engines + express + modularity + frameworks. It all develops into a pleasant \ comfortable – Tree folders