Reputation: 11
I got this error GET http://localhost:3000/assets/index.js net::ERR_ABORTED 404 (Not Found)
const express = require ('express')
const app = express()
const { join } = require('path')
app.use(express.static(join(__dirname,'/public')))
my folder structure:
the js is for survey.html:
<script src="/assets/index.js"></script>
anyone know why I got this error?
i tried
<script src="./assets/index.js"></script>
doesn't work
Upvotes: 1
Views: 61
Reputation:
It should be app.use(express.static(join(__dirname,'public')))
. adding /
to the public
means it looks in the root filesystem.
EDIT:
Oh, it is actually in the comment:
app.use(express.static(join(__dirname,'public'))) Use this – Yatin Gaikwad
Upvotes: 2