首页 > 解决方案 > 为什么我无法访问我网站的 aboutus.html 页面的 NPM 模块?

问题描述

找不到我的 aboutus.html 页面所需的 NPM 模块,并且出现 404 错误。不过,一切都适用于 index.html。

我查看了 NPM 服务器,解析的路径似乎是错误的:

19.01.20 22:33:07 304 GET /index.html
19.01.20 22:33:07 404 GET /aboutus.html/node_modules/bootstrap/dist/css/bootstrap.min.css

这是来自 Chrome 检查器:

http://localhost:3000/aboutus.html/node_modules/bootstrap/dist/js/bootstrap.min.js net::ERR_ABORTED 404 (Not Found)

这是我在代码中的路径: <link rel="stylesheet" href="node_modules/bootstrap/dist/js/bootstrap.min.js">

aboutus.html 页面位于我的文件夹的根目录中,所以我不明白为什么 NPM 在我的路径前面添加 aboutus.html/。index.html 不会发生这种情况。

我已经尝试在路径前添加 / 和 ../ 但没有成功。

请多多包涵,因为这是我在这里的第一个问题,而且我也是 Web 开发领域的新手。谢谢!

标签: npm

解决方案


我解决了。问题在于从index.html页面到aboutus.html页面的链接方式错误。

这是之前的链接方式:

<a class="nav-link" href="./aboutus.html/">About</a>

这就是我将行更改为:

<a class="nav-link" href="aboutus.html">About</a>

我希望这对遇到同样问题的人有所帮助。


推荐阅读