Should my Vue plugin that i'm about to publish depend on Vue itself? - vue.js

I wrote a Vue (2) plugin and am about to publish it to NPM. The question is should the plugin's package.json contain
"dependencies": {
"vue": "^2.5.21"
}
I'm pretty sure it should because it's clear that the plugin won't work without Vue itself. But at the same time i'm doubting: who would even try to use Vue plugin without Vue already installed as a project's dependency? And if I don't add it to the dependencies list then how would I be able to specify which versions of Vue the plugin does work with? (For example, if a user uses Vue 2.1.3 and my plugin will only work with versions starting from 2.5.17)

Related

Does Nuxt Bridge migration upgrade to Vue 3 as well?

I recently updated our app to use Nuxt Bridge following this guide:
https://v3.nuxtjs.org/bridge/overview
We were previously on Vue 2.7.10 but now when I check my vue version using npm view vue version I get 3.2.39.
But If I go into node_modules/vue/package.json I see this:
"name": "vue",
"version": "2.7.10",
I tried deleting node_modules, yarn.lock, .nuxt and explicitly added "vue":"3.2.39" to package.json then redid yarn install. After that I got an error about nuxt Cannot find module 'nuxt'.
So I guess my questions are: How can I tell which version of Vue I'm actually using in this project?
My goal is to upgrade to Vue 3, is there an issue with Nuxt Bridge and Vue 3?

Use a specific version of Vue for a Quasar project

When I started a new Vue project with Quasar, it installed the latest version of Vue which is 3.2.33, however I want to use 3.2.30.
How can I roll back or change it to that version of Vue?
You can fix a specific version to be used via the following in your package.json
{
"dependencies": {
"vue": "3.2.30"
},
}
Regarding the Quasar CLI, it creates a project with the following by default
Regarding semver, since it's ^3.0.0, the range will be >=3.0.0 and <4.0.0.
So every news project built by Quasar will be using the stable MAJOR v3 and the latest MINOR + PATCH versions.
You cannot change that properly.
(you could of course hack it yourself by keeping your own frozen version of Quasar or risk to edit it in your yarn.lock but I heavily recommend against that)
At the end, the project may use something lately released by the Vue core team or a critical fix. If the dev team of Quasar requires this change but you hacked it, you may experience some weird bugs that you will have no idea of the source (on top of other possible conflicts/issues).
TLDR: use the latest version of Vue (as intended by the Quasar team) or maybe lock a specific version of quasar that is fitting your needs regarding the Vue version.
You will not risk anything doing that.
PS: Quasar ^1.0.0 is used for Vue2 apps. If you want to see if some specific versions of Quasar are running some specific frozen versions of Vue, you can always dig deep into the releases of the project.

Do I need the #vitejs/plugin-vue dependency?

I'm trying to migrate a Vue2 project from Vue-CLI/Webpack to Vite. This migration guide says #vitejs/plugin-vue should be added as a dev dependency, but I'm not sure if I really need it, or if I do, which version I should use?
The documentation on GitHub doesn't say much about what this plugin is for, or when it should be installed.
#vitejs/plugin-vue is for Vue 3. You can use vite-plugin-vue2 for Vue 2.
I made a sample project with Vite, Vue2 and TailwindCSS that you can test / fork on stackblitz.
https://stackblitz.com/edit/vitejs-vite-hu1crh

Nuxt Buefy components using CDN

I am new to nuxt. I want to know whether is it possible to use Buefy on nuxt just by using CDN
as I directly imported beufy CDN in script in head function of nuxt.config
But it gave error while using navbar of beufy that the component is not registered correctly.
Nuxt supports buefy by default, when installing using npx create-nuxt-app you'll be asked if you want to use a component framework (buefy is an option here).
If you want to use it in an installed project you can npm install buefy --save and then add "nuxt-buefy" in the modules array of your nuxt.config

How to check a projects vue.js version?

I use Ubuntu 16.04 and I'd like to know how I check the vue.js version used by my project.
How do I do that?
Let's summarize the solutions from #jonrsharpe, #JamesAMohler and #MartinCalvert for friends looking for a quick answer.
Run npm list vue (or npm list --depth=0 | grep vue to exclude packages' dependencies). It is a common way to check npm package's version in the terminal.
Of course, you can also check vuejs's version by browsing package.json (or use command like less package.json | grep vue).
Use Vue.version during the runtime. It is a global API provided in vue.js.
If you have the Vue.js Chrome dev tool extension installed and your application is built in development mode you can simply open up the Chrome Dev Tools and use the Vue extension tab. It is clearly displays the Vue version for the project at the top (see below)
Please simply try type npm v vue in terminal to check the version of Vue.js
This is what worked for me:
import Vue from 'vue'
alert(`Vue version : ${Vue.version}`);
If you want to check the current version of Vue installed in your machine use vue --version
If you want to check the Vue installed on the project then use npm list | grep vue#
There are few ways to check vue version:
npm v vue run this on the terminal
Check package.json, code will be something like this
"dependencies": {
"core-js": "^3.6.5",
"vue": "^2.6.11"
},
If you have vue dev tools installed then go to the Vue tab and you should be able to see the version there.
Note: If you use vue --version - this will check vue cli version, not Vue version
It can be checked from package.json file. Inside dependencies block you can see vue and its version.
"dependencies": {
"vue": "^2.6.11"
}
if you have installed vue dev tools extension like I recommend, you can just press ctrl + shift + i at least in the firefox and then look with vue extension picture
You can also just use npm v vue in command prompt, you cant use vue --version becausue this checks what Vue CLI you have
You can only use npm v vue in CLI/ in Terminal, you can't use vue --version, it shows error enter image description here
For the solution of in-app version showing for vue version 3+.
As #ray-foss mentioned: I am only able to use
import {version} from "vue";
console.log('Vue version', version);
The way using import Vue from 'vue' does not work anymore (for me).
You can also type to check the Vuejs version vue --version