0

I am currently using Webpack as a build system and have set up everything properly so that it was working well.

All of the sudden, it started giving me an error stating:

[Vue warn]: Cannot find element: #app

I tried running the beforeCreated() hook on the root instance itself, where if the element does not exist I manually create it. But to no avail.

I have uploaded my code to Gitub, with a package.json file. It would be really amazing if someone can take a look and provide a solution.

I went spend hours going trough the code and even removed all other dependencies, but the most basic configurations, changed the import order and it still doesn't work.

Here is the link to the Github repo: Github

5
  • The code that created the #app div is commented out right now. Commented Jun 12, 2018 at 19:54
  • Yes, but it didn't work with it either. The element exists in a component which is imported prior to the Vue instance Commented Jun 12, 2018 at 20:01
  • Either you create the element before and mount the vue after, or you put a <div id="app"></div> in the index.html before the js bundle. Commented Jun 12, 2018 at 20:06
  • I downvoted because questions seeking debugging help should have a minimal reproducible example in the question itself. The comment was just to try and help anyway. Commented Jun 12, 2018 at 20:08
  • Relevant canonical question/answers Commented Jun 12, 2018 at 20:39

1 Answer 1

2

I think you are missing a #app element in the index.html to mount the app:

<body>
    <div id="app"></div>
    <script src="/dist/build.js"></script>
</body>
Sign up to request clarification or add additional context in comments.

1 Comment

The problem is that Vue cannot be mounted on <html> or <body> it has to use another element

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.