简体   繁体   中英

How do I load a file in a parent directory using http-server?

Setup

index.html

<link rel="stylesheet" type="text/css" href="../../css/styles.css"/>
<script type="text/javascript" src="../../lib/d3/d3.js"></script>

After going to localhost:8080. I get the following errors:

[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (styles.css, line 0)
[Error] Failed to load resource: the server responded with a status of 404 (Not Found) (d3.js, line 0)
[Error] ReferenceError: Can't find variable: d3 global code (localhost, line 16)

How do I fix this?

The solution I see as of now is running http-server in parent directory and then on running server accessing file in child directory.

for say: I have a src folder and inside that I have example folder having index.html file. src also contains abc.js which I want to use in index.html.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM