0

I'm currently trying to get Vuejs running in an existing project, but I'm constantly getting the mentioned error in the title when importing a component to the app.js. Unlike all other posts on Stackoverflow I found, I'm not trying to import a JavaScript file to a HTML File via the script tags.

My Code for the app.js looks like this:

import Vue from 'vue';
import exampleComponent from './components/exampleComponent.vue';

Vue.component('exampleComponent', exampleComponent);

const app = new Vue({
    el: '#vueApp'
});

I'm really desperate at this point of time, because I've been failing at this error for hours now.

The only possibility I could imagine regarding the error is that I failed initialize something crucial since I'm trying to add Vue to an existing app. I only installed Vue via npm AND thanks to my desperate mood embedded a cdn script for vuejs (the featured on of the website of vue) to my index.php. Maybe there is a dev server missing or I even have to install webpack etc.

Do you know a solution or have you experienced something similar?

Thanks in advance, J0nny

** EDIT ** I'm sorry I apparently did not post the whole code.

ExampleComponent.vue:

<template>
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-md-8">
                <div class="card card-default">
                    <div class="card-header">Example Component</div>

                    <div class="card-body">
                        I'm an example component.
                    </div>
                </div>
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        name: 'exampleComponent',
        mounted() {
            console.log('Component mounted.')
        }
    }
</script>

Index.php:

only containing #vueApp and the cdn

J0nny
  • 11
  • 7

1 Answers1

0

This is not really an answer - so apologies to the moderators/community - but I don't have enough reputation to comment.

You are able to compile without webpack using the CDN/ route according to this answer. So if @sovalina's answer did not help (which seemed the obvious thing), perhaps there is an issue within your HTML/template? Could you post that or a fiddle?

bigsee
  • 927
  • 8
  • 14