0

I get error 404 when trying to get the path of my css and js files. Any help will be appreciated, I'm using Laravel 5.8

<link href="{{asset('./public/css/bootstrap-datepicker.css')}}" rel="stylesheet">

<script src="{{asset('./public/js/jquery.js')}}"></script>

<script src="{{asset('./public/js/bootstrap-datepicker.js')}}"></script>

Here's my directory

enter image description here

Question 2: How can I access the files from node_modules? I also get error 404

This is my code for accessing node_modules files:

<link href="{{asset('dist/css/datepicker.min.css')}}" rel="stylesheet" type="text/css">
<script src="{{asset('dist/js/datepicker.min.js')}}"></script>

<!-- Include English language -->
<script src="{{asset('dist/js/i18n/datepicker.en.js')}}"></script>

enter image description here

1
  • Try using this..... href="{{asset('css/bootstrap-datepicker.css')}}" Commented Sep 23, 2019 at 8:29

4 Answers 4

1
<link href="{{asset('css/bootstrap-datepicker.css')}}" rel="stylesheet">

<script src="{{asset('js/jquery.js')}}"></script>

<script src="{{asset('js/bootstrap-datepicker.js')}}"></script> 

this the right answer... :D

Sign up to request clarification or add additional context in comments.

1 Comment

you cant access node modules. you need to compile. here's the docs laravel.com/docs/5.5/mix
1

Try removing the './' and just do

<link href="{{asset('public/css/bootstrap-datepicker.css')}}" rel="stylesheet">

Comments

0

Please try this and replace

<link href="{{asset('./public/css/bootstrap-datepicker.css')}}" rel="stylesheet">

to

<link href="{{URL::asset('css/bootstrap-datepicker.css')}}" rel="stylesheet">

The asset will get the path of the public folder.

Hope this will work.

Comments

0

For CSS:

<link href="{{ asset('css/bootstrap-datepicker.css') }}" rel="stylesheet" type="text/css" >

Make your directory structure is like this for CSS: /public/css/bootstrap-datepicker.css


For Javascript:

<script type="text/javascript" src="{{ URL::asset('js/jquery.js') }}"></script>
<script type="text/javascript" src="{{ URL::asset('js/bootstrap-datepicker.js') }}"></script>

Make your directory structure is like this for JS:

/public/js/jquery.js
/public/js/bootstrap-datepicker.js

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.