我的问题是新的,我以前没有,因为我使用http-sever包使本地主机为我的项目.问题是,当我修改JavaScript文件或任何其他文件,我做了刷新页面ctrl + r,这个包看不到JavaScript文件,不更新旧文件.
为了解决这个问题,我必须关闭http服务器,然后操纵端口,然后运行http服务器,以便更新JavaScript文件并在命令行中显示它!
那么问题的原因是什么呢?
修改:
每次页面刷新时应在文件中显示的结果:
[2022-08-25T19:10:29.858Z] "GET /pages/" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.460Z] "GET /pages/home.html" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.539Z] "GET /css/css/fontello-embedded.css" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.546Z] "GET /css/project.css" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.548Z] "GET /css/css/normalize.css" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.558Z] "GET /css/css/slick.css" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.593Z] "GET /js/tools/html5shiv.min.js" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.603Z] "GET /js/project.js" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.609Z] "GET /js/tools/jquery-3.6.0.min.js" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.611Z] "GET /js/tools/jquery.countdown.min.js" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.613Z] "GET /js/tools/slick.min.js" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.688Z] "GET /images/header/logo.png" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.699Z] "GET /images/page-01/part-01/01.png" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.712Z] "GET /images/page-01/part-01/02.png" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.720Z] "GET /images/page-01/part-02/01.jpg" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.726Z] "GET /images/page-01/part-04/week.png" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.734Z] "GET /images/page-01/part-05/01.jpg" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.745Z] "GET /images/page-01/part-05/02.jpg" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.761Z] "GET /images/page-01/part-05/03.jpg" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.769Z] "GET /images/page-01/part-05/05.jpg" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.774Z] "GET /images/page-01/part-05/06.jpg" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.776Z] "GET /images/page-01/part-05/04.jpg" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.779Z] "GET /images/page-01/part-06/01.jpg" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.783Z] "GET /images/page-01/part-02/02.jpg" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.785Z] "GET /images/page-01/part-02/03.jpg" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.800Z] "GET /images/page-01/part-03/01.jpg" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.805Z] "GET /images/page-01/part-03/02.jpg" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.814Z] "GET /images/page-01/part-03/03.jpg" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.819Z] "GET /images/page-01/part-03/04.jpg" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.845Z] "GET /images/page-01/part-03/05.jpg" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.865Z] "GET /images/page-01/part-03/06.jpg" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.867Z] "GET /images/page-01/part-03/08.jpg" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.870Z] "GET /images/page-01/part-03/07.jpg" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.879Z] "GET /images/page-01/part-06/02.jpg" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.882Z] "GET /images/page-01/part-06/03.jpg" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.885Z] "GET /images/footer/logo.png" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:31.887Z] "GET /images/footer/payment.png" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:47.091Z] "GET /images/page-02/01.jpg" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0" [2022-08-25T19:10:47.097Z] "GET /images/page-02/03.jpg" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0"
结果表明:
[2022-08-25T19:18:06.718Z] "GET /pages/shopping-cart.html" "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:104.0) Gecko/20100101 Firefox/104.0"
修改二:
激活此软件包时显示的结果
`D:\project-1\dest
λ http-server
Starting up http-server, serving ./
http-server version: 14.1.1
http-server settings:
CORS: disabled
Cache: 3600 seconds
Connection Timeout: 120 seconds
Directory Listings: visible
AutoIndex: visible
Serve GZIP Files: false
Serve Brotli Files: false
Default File Extension: none
Available on:
http://192.168.1.10:8080
http://127.0.0.1:8080
Hit CTRL-C to stop the server`
修改3:
我已尝试使用以下命令从设备中删除软件包
npm uninstall -g http-server
并通过命令重新安装
npx http-server
而且问题仍然存在!
注:
- npm版本:版本12.18.3
- 软件包版本:版本14.1.1
1条答案
按热度按时间6ju8rftf1#
我找到了解决方案。解决方案很简单,我禁用该高速缓存,同时通过-p快捷方式添加一个端口,这就是之前所有解决方案中的问题,之前的解决方案只讨论删除缓存,而没有在删除后添加端口
因此,解决方案的代码为:
8081仅用于测试,坦率地说,我喜欢这个数字,并希望始终使用它
感谢tom和Jhow的帮助
注:此解答取自此问题
特别是从最佳答案中。
我建议你看看讨论中发生的最佳答案。