2

I've run npm run watch and received the message

This dependency was not found:

*  in ./resources/assets/js/app.js

To install it, you can run: npm install --save 

So I ran npm install --save but still get the same message.

From my understanding, I need npm run or npm run watch to load the Vue files in Laravel.

For example, in 'resources/assets/js/components/Example.vue' file, I made edits to it but when I load up 'resources/views/welcome.blade.php' file, which I have as follows, the update from Example.vue file does not load.

<!DOCTYPE html>
<html lang="{{ config('app.locale') }}">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">

        <title>Laravel</title>

        <!-- Fonts -->
        <link href="https://fonts.googleapis.com/css?family=Raleway:100,600" rel="stylesheet" type="text/css">

        <!-- Styles -->
        <style>
            html, body {
                background-color: #fff;
                color: #636b6f;
                font-family: 'Raleway', sans-serif;
                font-weight: 100;
                height: 100vh;
                margin: 0;
            }

            .full-height {
                height: 100vh;
            }

            .flex-center {
                align-items: center;
                display: flex;
                justify-content: center;
            }

            .position-ref {
                position: relative;
            }

            .top-right {
                position: absolute;
                right: 10px;
                top: 18px;
            }

            .content {
                text-align: center;
            }

            .title {
                font-size: 84px;
            }

            .links > a {
                color: #636b6f;
                padding: 0 25px;
                font-size: 12px;
                font-weight: 600;
                letter-spacing: .1rem;
                text-decoration: none;
                text-transform: uppercase;
            }

            .m-b-md {
                margin-bottom: 30px;
            }
        </style>
    </head>
    <body>
        <div class="flex-center position-ref full-height">
            @if (Route::has('login'))
                <div class="top-right links">
                    @if (Auth::check())
                        <a href="{{ url('/home') }}">Home</a>
                    @else
                        <a href="{{ url('/login') }}">Login</a>
                        <a href="{{ url('/register') }}">Register</a>
                    @endif
                </div>
            @endif

              <div id="app">
                <example></example>
              </div>

            <div class="content">
                <div class="title m-b-md">
                    Laravel
                </div>

                <div class="links">
                    <a href="https://laravel.com/docs">Documentation</a>
                    <a href="https://laracasts.com">Laracasts</a>
                    <a href="https://laravel-news.com">News</a>
                    <a href="https://forge.laravel.com">Forge</a>
                    <a href="https://github.com/laravel/laravel">GitHub</a>
                </div>
            </div>
        </div>


        <script src='js/app.js'></script>
    </body>
</html>

(I only added in the script src link and the div with the 'app' id and the 'example' component)

What must I do to load the changes made to the Example.vue file? After this, I need to create new components in Vue.js in Laravel as well for my application.

llobet
  • 2,672
  • 23
  • 36
Simon Suh
  • 10,599
  • 25
  • 86
  • 110

2 Answers2

2

You need to run :

npm install

then :

npm run dev 
Amr Aly
  • 3,871
  • 2
  • 16
  • 33
  • I did this and now my component doesn't show up at all. – Simon Suh Apr 09 '17 at 20:01
  • How did you modify your example component? – Amr Aly Apr 09 '17 at 20:02
  • I only changed the text within the div from 'I'm an Example component' to 'I'm an example component that is now changed' – Simon Suh Apr 09 '17 at 20:08
  • the js file that I loaded into the welcome.blade.php file is js/app.js but I know I somehow need to load the resources/assets/js/app.js file but I don't know how. – Simon Suh Apr 09 '17 at 20:08
  • is your component is registered in your app.js file – Amr Aly Apr 09 '17 at 20:16
  • I think it is, what would the code be for registering it? this is what I currently have in my resources/assets/js/app.js file - (Vue.component('example', require('./components/Example.vue'));) – Simon Suh Apr 09 '17 at 20:18
  • try to restart your server – Amr Aly Apr 09 '17 at 20:25
  • try to wrap up all your body content in to `
    ` except for script tags
    – Amr Aly Apr 09 '17 at 20:30
  • just restarted my xampp file, still not working. Why did the component stop working after I ran 'npm run dev'? – Simon Suh Apr 09 '17 at 20:33
  • before I ran 'npm run dev' the component that comes preinstalled on a new laravel installation was showing up, though I couldn't change the contents of the component. After I ran 'npm run dev', the component no longer works either. – Simon Suh Apr 09 '17 at 20:40
  • i see, try to use `npm run watch` – Amr Aly Apr 09 '17 at 20:43
  • one last thing try to create a new blade and render the example component into it but don't forget import your app.js – Amr Aly Apr 09 '17 at 20:53
  • Hey Amr, I remade a question here in hopes of getting a better answer, would love your insight :) http://stackoverflow.com/questions/43312756/how-do-i-make-example-vue-update-in-laravel – Simon Suh Apr 09 '17 at 22:51
0

Eventually I figured it out what happens. I don't know why exactly but I have got the answer:

You are trying to include a vue component in a non-layout page like welcome.blade.php. Try wrapping this single page in a layout and add your component, in this case <example></example>. Be sure you are linking to your app.js.


Updated: This is what happens exactly: Answer.

Community
  • 1
  • 1
llobet
  • 2,672
  • 23
  • 36