My code snippet looks like this:
<script type="text/javascript" src="../../node_modules/requirejs/require.js"></script>
<script type="text/javascript" src="../../node_modules/vue/dist/vue.js"></script>
<script>console.log(Vue)</script>
This results in the following error:
Uncaught ReferenceError: Vue is not defined
To resolve this issue, I found that the following code works correctly:
<script type="text/javascript" src="../../node_modules/vue/dist/vue.js"></script>
<script>console.log(Vue)</script>
In addition, this alternative code also functions properly:
<script type="text/javascript" src="../../node_modules/requirejs/require.js"></script>
<script>
requirejs(["../../node_modules/vue/dist/vue.js"], (Vue) => {
window.Vue = Vue;
console.log(Vue)
})
</script>
I am curious why using requirejs causes window.Vue to be null. Is there a way to import Vue with requirejs that behaves the same as importing Vue without requirejs?