1

I'm new to Vue, this may seem a basic question but I'm stuck with this problem:

I have installed Vue 3 using npm, according to the documentation:

https://v3.vuejs.org/guide/installation.html#npm

I have included Vue to my html file, like so:

<script src="../node_modules/vue/dist/vue.csj.js"></script> 

But I get this error in the console:

vue.cjs.js:3 Uncaught ReferenceError: exports is not defined at vue.cjs.js:3 (anonymous) @ vue.cjs.js:3

I have seen some similar issues and I know it has something to do with browser compatibility and webpack; like the browser does not natively recognise import/export commands but it seems like everything is installed correctly and I don't know how to solve this issue. I couldn't find anything helpful in the documentation.

So my question is

How do I successfully install Vue and include it in my working files?

2 Answers 2

1

I don't think you followed that guide correctly. I would recommend you install the Vue CLI, then create your app using the cli:

$ npm install -g @vue/cli - install cli

$ vue create my-app

https://cli.vuejs.org/

However, if you don't want the CLI, I'd recommend a CDN:

<script src="https://unpkg.com/vue@next"></script>

Or you can just copy the contents of the file to your app, maybe vue.js (https://unpkg.com/vue@next).

And you then on your html <script src="vue.js"></script>

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. Actually tried that but I ended up giving up as It gives me an error: vue command not found. Probably it's something to do with paths tho. Anyway, I thought I could just use npm without having to install the CLI. Thank you for the clarifications.
1

Firstly , npm install -g @vue/cli After , on commandline run vue ui and create a project

1 Comment

Thank you. Actually tried that but I ended up giving up as It gives me an error: vue command not found.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.