O
O
OWIII2020-11-25 23:33:00
Node.js
OWIII, 2020-11-25 23:33:00

Node server doesn't see scripts folder?

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

const app = express();
const port = 3000;

app.use(express.static(path.join(__dirname, '..', 'app')));

app.get('/', (req, res) => {
    res.sendFile(path.join(__dirname, '..', 'index.html'));
});

app.listen(port, () => {
    console.log('server is runnig');
});


I can not figure out the ways, tell me, please.

Project structure:
5fbebebd18af6304081923.png

Problem: express.static does not see files from the app folder.
I want to make express.static read any files from the app folder and nested inside.
The server file is located in another "server" folder.

Thank you in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
OWIII, 2020-11-26
@OWIII

Issue resolved.

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

const app = express();
const port = 3000;

app.use('/app',express.static(path.join(__dirname, '..', 'app')));

app.get('/', (req, res) => {
    res.sendFile(path.join(__dirname, '..', 'index.html'));
});

app.listen(port, () => {
    console.log('server is running');
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question