admin管理员组文章数量:1394526
I'm running into some frustrating 404 errors while working on a web project. I'm using this file structure for my CSS and JS files:
bower_ponents
bootstrap
|dist
|css
| bootstrap.min.css
angular
|angular.min.js
jquery
|dist
|jquery.min.js
dist
lib
|farbtastic.js
node_modules
src
|img
|styles
|scripts
|view1
|view2
|index.html //running browserSync from this folder using this file as index
When I try to reference files in index.html
using the appropriate syntax:
<link rel="stylesheet" type="text/css" href="../bower_ponents/bootstrap/dist/css/bootstrap.min.css">
I get a 404 "Failed to load resource" error.
The ../
syntax appears to be correct, and my console shows that it's looking in the correct location in http://localhost:3000/bower_ponents/bootstrap/dist/css/bootstrap.min.css
.
Is there something I'm not doing correctly?
I'm running into some frustrating 404 errors while working on a web project. I'm using this file structure for my CSS and JS files:
bower_ponents
bootstrap
|dist
|css
| bootstrap.min.css
angular
|angular.min.js
jquery
|dist
|jquery.min.js
dist
lib
|farbtastic.js
node_modules
src
|img
|styles
|scripts
|view1
|view2
|index.html //running browserSync from this folder using this file as index
When I try to reference files in index.html
using the appropriate syntax:
<link rel="stylesheet" type="text/css" href="../bower_ponents/bootstrap/dist/css/bootstrap.min.css">
I get a 404 "Failed to load resource" error.
The ../
syntax appears to be correct, and my console shows that it's looking in the correct location in http://localhost:3000/bower_ponents/bootstrap/dist/css/bootstrap.min.css
.
Is there something I'm not doing correctly?
Share Improve this question asked Dec 30, 2015 at 15:02 ThassaThassa 5428 silver badges27 bronze badges2 Answers
Reset to default 5The root directory of your application is the "src" folder. When you request bootstrap.min.css from "../bower_ponents/", you are telling the browser to go 1 level up. Because you are already at the root of the application, "../bower_ponent" is essentially doing the same as "bower_ponent".
You can:
1. move your index.html 1 level up
2. move your bower_ponents inside src
3. have some kind of build(gulp/grunt) to reorganize them in a way where the bower_ponents is within the root folder.
Since root directory of your application is src
folder, you can still load from bower_ponents using the link
<link rel="stylesheet" type="text/css" href="../bower_ponents/bootstrap/dist/css/bootstrap.min.css">
configure you browserSync.init
this way
browserSync.init({
server: {
baseDir :"src",
routes:{
"/bower_ponents" : "bower_ponents"
}
}
本文标签: javascriptFailed to load resource from bowercomponents even with correct file pathStack Overflow
版权声明:本文标题:javascript - Failed to load resource from bower_components even with correct file path - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744093960a2589938.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论