setting content type for static javascript files in express setting content type for static javascript files in express express express

setting content type for static javascript files in express


it needed a mount path. '/src' in -

app.use( '/src', express.static( __dirname + '/src' ) );

not sure why though. will update.


The content type should be automatically determined by the file extension.

<script type="module" src="./src/test.js"></script>

You probably want to remove /src from the script path if you don't want to mount the static directory to /src in your express app.