I have a project with the following structure:
project | -
public | -
-index.html
src | -
-index.js
and the code to import the file is :
<script src="../src/index.js"></script>
and it doesn't work. Any ideas why?
Assuming that public is the only directory exposed with a URL (i.e. you access index.html with http://example.com/index.html): you can't.
The browser can only access the file by requesting its URL, and if you've not put it in public then it doesn't have a URL.
Either: