-1

I have a folder with html files, a css file, and a javascript file along with images that I want to display in node.js. Is it possible to use all of that code already written and display that in a node.js app or would I have to recreate everything in node.js specifically? I've displayed the first html page, but the css and javascript I used does not work.

2
  • "display in nodejs" i guess you are new to node.js i would recommend to google for "express.js" and "ejs template engine" so set up an express server with ejs template Commented Oct 24, 2019 at 18:33
  • have a look at this: expressjs.com/en/starter/static-files.html Commented Oct 24, 2019 at 18:42

1 Answer 1

-1

The easiest way would be to use a framework like Express to serve your static files.

Here's how you would do something like this in express:

const express = require('express');
const app = express();

// Serves files in the public folder to the / route
app.use('/', express.static('public'));

// Use port 3000 for the server
app.listen(3000);

If your interested in doing it without Express (which I would not recommend) here is a example I found and a article as well.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.