简体   繁体   English

Node.JS引导程序404尝试获取dist / js / login

[英]Node.JS bootstrap 404 trying to get dist/js/login

I have a webapp running on my local machine. 我在本地计算机上运行了一个Webapp。 In an HTML file, I have a script src as /node_modules/bootstrap/dist/js/bootstrap.js . 在一个HTML文件中,我有一个脚本src作为/node_modules/bootstrap/dist/js/bootstrap.js I have set up a route in my Routes.js file to handle this request and return the correct file (bootstrap.js). 我已经在Routes.js文件中设置了一条路由来处理此请求并返回正确的文件(bootstrap.js)。

However, after setting up the route, I'm getting a 404 error on 但是,设置路线后,我收到404错误

/node_modules/bootstrap/dist/js/login

I tried setting up a route on this exact call to see if I couldn't get some information about it, but I was hit with a error: 我尝试在此确切的呼叫上设置一条路由,以查看是否无法获取有关此路由的信息,但遇到错误:

Too many redirects

I have bootstrap installed through NPM, and my app is able to load all the other bootstrap resources in the folder. 我已经通过NPM安装了引导程序,并且我的应用程序能够加载该文件夹中的所有其他引导程序资源。

Thanks in advance! 提前致谢!

Edit: The only code that I can see that is relevant are two pieces. 编辑:我可以看到的唯一相关代码是两部分。 The first is that the html file in question is within project_root/public/html/index.html and the bootstrap folder is in project_root/node_modules/bootstrap/dist/js/bootstrap.js The second is that the line that is causing the 404 is <script src='/node_modules/bootstrap/dist/js/bootstrap.js'></script> 第一个是相关的html文件位于project_root/public/html/index.html ,而bootstrap文件夹位于project_root/node_modules/bootstrap/dist/js/bootstrap.js 。第二个是导致404的行是<script src='/node_modules/bootstrap/dist/js/bootstrap.js'></script>

I'm just not sure why that html line is looking for "login" 我只是不确定为什么该HTML行正在寻找“登录”

Edit 2: Stupid mistake on my part. 编辑2:我的愚蠢错误。 I didn't have the route available without authentication. 没有身份验证,我没有可用的路由。 Sorry! 抱歉!

You ordinarily wouldn't try to reference your dependencies from within the node_modules folder. 通常,您不会尝试从node_modules文件夹中引用您的依赖项。 Rather, you would have some kind of build process which copies (and optionally does other tasks like uglification / minification) to a folder within your web application server - usually a public directory etc. You would then reference the contents of that public folder from your HTML page instead. 而是,您将具有某种生成过程,该过程会将Web应用程序服务器中的文件夹(通常是公共目录等)复制(并可选地执行其他任务,例如uglification / minification),然后从您的目录中引用该公共文件夹的内容。 HTML页面。

Unclear what your setup is, can you offer more information? 不清楚您的设置是什么,可以提供更多信息吗? Which webserver etc etc. 哪个网络服务器等

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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