Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

afoysal's avatar

[Vue warn]: Cannot find element: #app

I am working on a Laravel app where VueJS integrated inside Larevel Blade file. I added app.js file like below.

if(Request::is('admin/time')) {
            <script src="{{ asset('js/app.js') }}" async defer></script>
        }
    </body>
</html>

But I am getting error [Vue warn]: Cannot find element: #app. If I visit VueJS component page I am not getting error. But if I visit other pages I am getting error.

I added #app is like below.

const app = new Vue({
    el: '#app',
});
0 likes
11 replies
Tray2's avatar

You need to have an element in your view with the id of app

<div id="app></div>
1 like
afoysal's avatar

@Sinnbeck Thanks. I did it previously when I was getting that error. Error is not solved. Thanks.

Sinnbeck's avatar

@afoysal Then open the dev tool (F12 -> elements) and see if you can find <div id="app></div>. My bet is that it isnt there

1 like
afoysal's avatar

@Sinnbeck Thanks. I added app id in a blade file. If I browse that page then I am not getting that error. But if I browse other pages then I am getting this error. I am using VueJS component in a blade file. Thanks.

Sinnbeck's avatar

@afoysal So those pages that does not work. Do they have the div mentioned above ? Are you routing in laravel or vue ?

1 like
afoysal's avatar

@Sinnbeck Thanks. I am routing Laravel. My blade file is like below.

@extends('layouts.admin.app')

@section('title', 'Time')

@push('css_or_js')
@endpush

@section('content')
    <div id="app">
        <time-component />
    </div>
@endsection
Sinnbeck's avatar

@afoysal And

So those pages that does not work. Do they have the div mentioned above ?

1 like

Please or to participate in this conversation.