E
E
Eugene2018-08-07 15:16:51
JavaScript
Eugene, 2018-08-07 15:16:51

JS-crypt gives html instead of js-code inside it based on express.js. What is the problem?

Good afternoon!
Ask for help from the community.
I am creating a simple express.js server:
const express = require('express');
const app = express();
app.get("*", (req, res) => {res.sendFile(__dirname + '/index.html');});
app.listen(8080, () => {console.log("Server is running!");});
I include scripts in the Index.html file: one script from the script.js file, the other just through the script tags.
The problem is that script.js doesn't work. It doesn't even connect! If you select this script in the "view page code", then not the text of the script is displayed, but again the html file.
The nested script works.
All documents are at the same nesting level (in the same folder).
Moreover, if you remove type="text/babel" when calling the script or write type="text/javascript", then a SyntaxError: Unexpected token < error is generated, pointing to the DOCTYPE directive.
I don't understand what's the matter. Hope someone can help :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Spirin, 2018-08-07
@Shagfey

Providing static files in Express

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question