Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vue 2 is not working with Meteor 2.12 #437

Open
Grubba27 opened this issue May 8, 2023 · 15 comments
Open

Vue 2 is not working with Meteor 2.12 #437

Grubba27 opened this issue May 8, 2023 · 15 comments

Comments

@Grubba27
Copy link

Grubba27 commented May 8, 2023

To reproduce:

meteor create vue-test --vue-2
meteor

Gives a big error but the summary of the error is this text below:

[vue-component] Error while compiling in tag <script> using lang js: Can't find handler for lang 'js', did you install it?
[vue-component] Error while compiling in tag <script> using lang js TemplatingTools is not defined
ReferenceError: TemplatingTools is not defined
    at throwCompileError (packages/vue-component/plugin/utils.js:200:15)
    at VueComponentTagHandler.getResults (packages/vue-component/plugin/tag-handler.js:87:13)
    at compileTags (packages/vue-component/plugin/vue-compiler.js:534:18)

As I was looking in the source code I found a snippet in packages/vue-component/plugin/tag-handler.js that does look like this:

const compile = global.vue.lang[lang] // maybe here is breaking?
if (!compile) {
/// error

tried in 0.16.0 and 0.15.3, and both break. Maybe it is unrelated to the vue-components package, but I'm unsure how to look into this.

@bslocombe
Copy link

@Grubba27 we found this issue too, and on updating one of our projects.

the issue seems to be this line that was added recently to the tag handler:

if (sfcBlock.type === 'script' && !sfcBlock.lang) {
sfcBlock.lang = 'js'
}

Which then forces the builder to look for compiler with options for JS vs just skipping the whole block and using babel to transpile the JS.

If you copy the vue-component package to your local packages and uncomment this line it should start working again.

You also need to make sure you have a version of vue-template-compiler that matches your vue version installed from npm too, otherwise it will complain that the version your using doesn't match (silently if you dont have the compiler debug on). since we are using [email protected] i had to also install the [email protected] to make things work properly.

@bslocombe
Copy link

Not sure if thats the best way to handle the issue, but submitted a PR for the workaround that works for me.

@eganpg
Copy link

eganpg commented May 16, 2023

Thank you. I've updated our project last night an am experiencing the same issue. Appreciate the work around.

@eganpg
Copy link

eganpg commented Jun 14, 2023

Adding follow up. It appears there is a difference between the atmosphere package and the latest repo.

  1. Create folder /packages
  2. Copy https://github.com/meteor-vue/vue-meteor/tree/master/packages/vue-component into step 1 folder
  3. Remove akryum:vue-component package

This solved the issue for us in multiple apps

@willibeach
Copy link

Meteor no longer supports Vue 2. We reset the entire development environment and then installed earlier versions of meteor (v.1.12.2 and then v 2.10.0). We even used meteor to create an entirely new project using the default scaffolding and that fails too. All this suggests something fundamental is wrong with the Vue-2 support for Meteor.

Here is the CLI list of procedures we followed:-

1. meteor-installer uninstall (remove meteor entirely)
2. npm install -g meteor
3. meteor create --vue-2 testApp
4. cd testApp (change directory to the testApp folder)
5. meteor install --release 1.12.2 (our original app was using release 1.x.x)
6. meteor (command to build & run the app)

We have made no changes to the testApp code - it is exactly the code created by the meteor scaffolder. When we run the meteor command to build & test the default App we get the following messages, which indicate that meteor no longer supports a Vue 2 application on an older (1.x.x) release.

**=> Errors while initializing project:

While selecting package versions:
error: Conflict: Constraint [email protected] is not satisfied by ecmascript 0.14.4.
Constraints on package "ecmascript":

Conflict: Constraint [email protected] is not satisfied by caching-html-compiler 1.2.0.
Constraints on package "caching-html-compiler":

Conflict: Constraint [email protected] is not satisfied by templating-tools 1.2.0.
Constraints on package "templating-tools":

We then decided to install meteor version 2.10.0, which is slightly older than the latest release, by running the command:

meteor install --release 2.10.0

When the meteor command is run it now produces the following Error messages, which are exactly the same error messages we get when attempted to build & run our original app which has failed ever since we upgraded Meteor and we're now unable to revert to an earlier version. All this suggests that we can't even run a vue 2 app using an older release, whether versions 1.12.2 or 2.10.0 :-

=> Started proxy.
=> [HMR] Dev server listening on port 3003.
[vue-component] Error while compiling in tag <script> using lang js: Can't find handler for lang 'js', did you install it?
[vue-component] Error while compiling in tag <script> using lang js TemplatingTools is not defined
ReferenceError: TemplatingTools is not defined
at throwCompileError (packages/vue-component/plugin/utils.js:200:15)
at VueComponentTagHandler.getResults (packages/vue-component/plugin/tag-handler.js:87:13)
at compileTags (packages/vue-component/plugin/vue-compiler.js:534:18)
at compileOneFileWithContents (packages/vue-component/plugin/vue-compiler.js:543:12)
at VueCompo.compileOneFile (packages/vue-component/plugin/vue-compiler.js:142:12)
at packages/vue-component/plugin/vue-compiler.js:58:34
at C:\Users\William\AppData\Local.meteor\packages\akryum_vue-component\0.16.0\plugin.vue-component.os\npm\node_modules\meteor\vue-component\node_modules\async\dist\async.js:3110:16
at replenish (C:\Users\William\AppData\Local.meteor\packages\akryum_vue-component\0.16.0\plugin.vue-component.os\npm\node_modules\meteor\vue-component\node_modules\async\dist\async.js:1011:17)
at C:\Users\William\AppData\Local.meteor\packages\akryum_vue-component\0.16.0\plugin.vue-component.os\npm\node_modules\meteor\vue-component\node_modules\async\dist\async.js:1016:9
at Object.eachLimit$1 (C:\Users\William\AppData\Local.meteor\packages\akryum_vue-component\0.16.0\plugin.vue-component.os\npm\node_modules\meteor\vue-component\node_modules\async\dist\async.js:3196:24)
at packages/vue-component/plugin/vue-compiler.js:42:11
at C:\Users\William\AppData\Local.meteor\packages\meteor-tool\2.12.0\mt-os.windows.x86_64\dev_bundle\lib\node_modules\meteor-promise\fiber_pool.js:43:40
[vue-component] Error while compiling in tag <script> using lang js: Can't find handler for lang 'js', did you install it?
[vue-component] Error while compiling in tag <script> using lang js TemplatingTools is not defined
ReferenceError: TemplatingTools is not defined
at throwCompileError (packages/vue-component/plugin/utils.js:200:15)
at VueComponentTagHandler.getResults (packages/vue-component/plugin/tag-handler.js:87:13)
at compileTags (packages/vue-component/plugin/vue-compiler.js:534:18)
at compileOneFileWithContents (packages/vue-component/plugin/vue-compiler.js:543:12)
at VueCompo.compileOneFile (packages/vue-component/plugin/vue-compiler.js:142:12)
at packages/vue-component/plugin/vue-compiler.js:58:34
at C:\Users\William\AppData\Local.meteor\packages\akryum_vue-component\0.16.0\plugin.vue-component.os\npm\node_modules\meteor\vue-component\node_modules\async\dist\async.js:3110:16
at replenish (C:\Users\William\AppData\Local.meteor\packages\akryum_vue-component\0.16.0\plugin.vue-component.os\npm\node_modules\meteor\vue-component\node_modules\async\dist\async.js:1011:17)
at C:\Users\William\AppData\Local.meteor\packages\akryum_vue-component\0.16.0\plugin.vue-component.os\npm\node_modules\meteor\vue-component\node_modules\async\dist\async.js:1016:9
at Object.eachLimit$1 (C:\Users\William\AppData\Local.meteor\packages\akryum_vue-component\0.16.0\plugin.vue-component.os\npm\node_modules\meteor\vue-component\node_modules\async\dist\async.js:3196:24)
at packages/vue-component/plugin/vue-compiler.js:42:11
at C:\Users\William\AppData\Local.meteor\packages\meteor-tool\2.12.0\mt-os.windows.x86_64\dev_bundle\lib\node_modules\meteor-promise\fiber_pool.js:43:40
[vue-component] Error while compiling in tag <script> using lang js: Can't find handler for lang 'js', did you install it?
[vue-component] Error while compiling in tag <script> using lang js TemplatingTools is not defined
ReferenceError: TemplatingTools is not defined
at throwCompileError (packages/vue-component/plugin/utils.js:200:15)
at VueComponentTagHandler.getResults (packages/vue-component/plugin/tag-handler.js:87:13)
at compileTags (packages/vue-component/plugin/vue-compiler.js:534:18)
at compileOneFileWithContents (packages/vue-component/plugin/vue-compiler.js:543:12)
at VueCompo.compileOneFile (packages/vue-component/plugin/vue-compiler.js:142:12)
at packages/vue-component/plugin/vue-compiler.js:58:34
at C:\Users\William\AppData\Local.meteor\packages\akryum_vue-component\0.16.0\plugin.vue-component.os\npm\node_modules\meteor\vue-component\node_modules\async\dist\async.js:3110:16
at replenish (C:\Users\William\AppData\Local.meteor\packages\akryum_vue-component\0.16.0\plugin.vue-component.os\npm\node_modules\meteor\vue-component\node_modules\async\dist\async.js:1011:17)
at C:\Users\William\AppData\Local.meteor\packages\akryum_vue-component\0.16.0\plugin.vue-component.os\npm\node_modules\meteor\vue-component\node_modules\async\dist\async.js:1016:9
at Object.eachLimit$1 (C:\Users\William\AppData\Local.meteor\packages\akryum_vue-component\0.16.0\plugin.vue-component.os\npm\node_modules\meteor\vue-component\node_modules\async\dist\async.js:3196:24)
at packages/vue-component/plugin/vue-compiler.js:42:11
at C:\Users\William\AppData\Local.meteor\packages\meteor-tool\2.12.0\mt-os.windows.x86_64\dev_bundle\lib\node_modules\meteor-promise\fiber_pool.js:43:40
=> Started MongoDB.

So if the above isn't a clear enough statement of the problems we're facing, and I suspect others invested in Meteor and Vue are too, then I don't know what is. All the above is using the default scaffolded app generated by meteor create --vue-2 testApp. Worst still, it appears one can't go back to an earlier release. As you can see above, we've tried running the default app with meteor 1.12.2 and 2.10.0.

This is a serious situation, especially for those invested in Metoer with Vue and a resolution to the problems needs immediate attention.

@willibeach
Copy link

Adding follow up. It appears there is a difference between the atmosphere package and the latest repo.

  1. Create folder /packages
  2. Copy https://github.com/meteor-vue/vue-meteor/tree/master/packages/vue-component into step 1 folder
  3. Remove akryum:vue-component package

This solved the issue for us in multiple apps

Can you elaborate how to fix the problem.

  1. We created a new folder called \packages in our Application directory which already has folders such as .meteor, \client, \imports, \node_modules, \server and \test
  2. We then changed to the packages folder i.e. cd packages
  3. We than ran git clone 'https://github.com/meteor-vue/vue-meteor.git', which created the folder \vue-meteor inside the packages folder.
  4. Then removed the akryum-vue-component folder from the global meteor installation which in our case is in directory User\William\AppData\Local.meteor\packages.

When we run meteor to build & run the app, meteor appears to first reinstall the missing vue-component package and reports the same error messages. Can you suggest what we've done wrong please?

@constantin-huetterer
Copy link

Can you elaborate how to fix the problem.

I think what he means in step 3. is to remove (or comment out) the akryum:vue-component from the packages file in the .meteor folder of your project.

@fracz fracz mentioned this issue Aug 10, 2023
@StrictlySkyler
Copy link

I'm blocked from upgrading pending this as well. @Akryum Are you able to update this or not? Looks like there's a potential fix proposed.

Thanks,

jbl2024 added a commit to jbl2024/latelier that referenced this issue Nov 2, 2023
jbl2024 added a commit to jbl2024/latelier that referenced this issue Nov 12, 2023
* Update project to meteor v2.13.3

* Fix counters

* Update packages

* Fix akryum:vue-component

see meteor-vue/vue-meteor#437

* Update jszip

* Add a makefile

* Update changelog

* Update docker files

* Update changelog

* Fix counter

* Add atomic update, like before

* Remove useless file

* Update changelg

* Add minio

* Update changelog
@anderson-2wav
Copy link

I have big investments in several meteor 2 / vue 2 applications that will be back-breaking to update to Meteor 3.

I gathered from the last comments from @jbl2024 that meteor 2.13.3 might fix the issue. I can confirm that a new meteor 2 vue 2 app created with 2.13.3 will launch without these errors. Yay.
meteor create --vue --release 2.13.3 meteor-vue-2 cd meteor-vue-2 meteor npm i meteor

Now how to update an existing app? In the existing app:
meteor update --release 2.13.3 updates a bunch of stuff, but running still has the error:
"TypeError: this._watchers is undefined"

In meteor-vue/vue-meteor-tracker#75, @Akryum says to stick to vue 2.6, but this app uses vue 2.6.14 (and has for long time). Thinking that akryum:vue-component may not have gotten updated with the update to 2.13.3, I tried meteor remove akryum:vue-component and meteor add akryum:vue-component. That changed something because now when I run the app I get this on the server:
[vue-component] Error while compiling in tag <script> using lang js: Can't find handler for lang 'js', did you install it? [vue-component] Error while compiling in tag <script> using lang js TemplatingTools is not defined

I tried the recipe suggested by @eganpg above (installing a local copy of GitHub due-component.
That builds successfully on the server, but on the client the app fails with:
Error: Cannot find module '/imports/ui/App.vue'

(btw using a relative path to App.vue makes no difference).

I so far have no path to create a runnable version of the app, although creating a new app with 2.13.3 succeeds. Any suggestions anyone?

@hluz
Copy link

hluz commented Jan 14, 2025

I was there. And been through all the options of upgrading a Meteor 2 / Vue 2.6 to Meteor 3 / Vue 3 (Options API), and what finally worked for me was avoiding akryum:vue-component and use meteor-vite instead. There are a few threads in the Meteor Forums that may help. I am still using the [email protected], which forced me to use a code few workarounds because it it not fully compatible with Vue 3 Options API.

@anderson-2wav
Copy link

@hluz I have started working in Meteor 3 on new projects, and I have some very painful similar experiences upgrading Nuxt 2 to Nuxt 3. A few of these complex Meteor 2 projects have grant funded deliverables that requiring a move to Meteor 3 in order to continue development is probably just the end of the project. I have found a copy of the project on an old x86 laptop that still runs, so maybe that will be our savior.

It seems stupid. I understand that all the energy and hope for the future is Meteor 3 and I'm down with that. But utterly breaking the Meteor 2 platform and leaving it that way is unconscionable.

@hluz
Copy link

hluz commented Jan 14, 2025

@anderson-2wav. You should be able to use meteor-vite with Meteor 2, but I think that for Vue 2 it requires Vue 2.7.

https://github.com/JorgenVatle/meteor-vite?tab=readme-ov-file#meteor-v2

@anderson-2wav
Copy link

@hluz Thanks! I admit I've been scared to go to vite with Meteor 2, but I should get over it and get on with it. ;-) And to all the meteor contributors I regret and apologize for my harsh tone. I'm hugely grateful for all my team has been able to do with Meteor, since 2012 actually.

@bslocombe
Copy link

We are largely in the same boat @hluz. We have some fairly complex vue2/meteor2 codebases using my fork of the meteor tracker. Upgrading to vue2.7 breaks badly without changing your tracker libraries to use meteor-vue-tracker as above. There was a magic combination of meteor-vue-tracker, meteor2, and vite that did work for us but enough little glitches we never ended up going with it, especially with other vue2 libraries in the mix. However migrating to vue3 requires meteor 3 from our testing, the options API seems poorly supported in vue3 which is not limited to meteor, and so significant effort and rewriting of both backend (async) code and front end (vue2 to vue3) and also vue3 options to composition API. For us, options API was what we loved about vue in the first place (and being able to drop it into older apps), and while we should have started this work ages ago we were holding off hoping it would get easier. We have committed to having to rework most of our app and have actually decided to move to svelte/meteor3 and react/meteor3 depending on the codebase/team instead of vue3/meteor3 while doing this. Not all bad, since we already use both for other smaller projects, and realistically we would have had to do much of this moving to vue3 anyway.

@hluz
Copy link

hluz commented Jan 15, 2025

Migration to Meteor 3 we had to do anyway, so we fixed the backend first to the async mongo API. Then we managed to stay with Vue3 Options API using vue-meteor-tracker latest beta. There are only a few things you have to do to make your subscriptions work nicely with options API:

  • Leave the meteor: {} object empty. This is important because we need to use this.$subscribe from the mounted() hook.
  • import autorun from vue-meteor-tracker.
  • $subReady is broken, so you need to capture it from the subscription handle.
  • since there is nothing inside the meteor object, you need to define any data variable needed for holding subscribed data.

The whole thing follows this pattern:

import { autorun } from 'meteor-vue-tracker'
import { CollectionA } from '/imports/db/CollectionA'

export default {
  data () {
    return {
      subReady: { // use this instead of $subReady
      },
      colAData: [],
      par1: 'default'
    }
  },
  meteor: {},
  mounted() {
    autorun(() => { // autorun not required if there is no reactive parameter for subscription
      this.subReady.subNameA = this.$subscribe('subNameA', { par1: this.par1 }).ready
    });

    autorun(() => {
      this.colAData = CollectionA.find({ par1: this.par1 }).fetch();
    });
  },

  ...

}

Note: meteor-vue-tracker does no support async calls yet... But I can live without sync since all my db updates are server side via method calls only.

Lets hope that better/easier Meteor Tracker integration with Vue 3 comes along.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants