gtm-support / vue-gtm

Simple implementation of Google Tag Manager for Vue
https://www.npmjs.com/package/@gtm-support/vue-gtm
MIT License
210 stars 27 forks source link

Bug: You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file.Because the code uses the null merge operator (??) #280

Open xuyanmei opened 2 years ago

xuyanmei commented 2 years ago

Info

Tool Version
Plugin ^2.0.0
Vue v2.x.x
Node 14.17.0
OS win

Input

const baseUrl = vueRouter.options.base ?? ""

Output or Error

You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders

Expected Output

Additional Context

in my nuxt project,npm run in vscode,It seems that the null value merge operator (??) is used。Previous versions using ^ 1.3.0 will not look like this

【error】 You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders

 const baseUrl = vueRouter.options.base ?? ""

@ ./plugins/gtm.ts 2:0-43 6:10-16

Shinigami92 commented 2 years ago

Which version of WebPack are you using?

I think the best option for you right now is to stay on v1.3.0 and wait until you can support modern environment code.

xuyanmei commented 2 years ago

WebPack

Thank you for your answer ,maybe "webpack": "^4.46.0",I thought that the high version might have solved many bugs

Shinigami92 commented 2 years ago

Ah yeah, v2.0.0+ is not compatible anymore with WebPack v4 Maybe it is with WebPack v5, but I highly recommend to try out Vite instead

fdsprop commented 1 year ago

I am having the same problem, how did you solved it?

juliantn commented 1 year ago

Same here using these versions...

"@gtm-support/vue-gtm": "^2.0.0" "webpack": "^4.46.0"

alfreema commented 1 year ago

Also having this issue.

@juliantn ...

Changing the package.json from:

"@gtm-support/vue2-gtm": "^2.0.0",

to

"@gtm-support/vue2-gtm": "^1.3.0",

got me to a running state.

makerovski commented 1 year ago

The solution from @alfreema does not work for me, any ideas ?

ljuborados commented 1 year ago

@makerovski add "@gtm-support/*" to transpileDepenencies in vue.config.js

makerovski commented 1 year ago

I got a solution for this, I use the tracking in a Method like :

 methods: {
    sendTracking() {
      this.$gtm.trackEvent({
        event: "form-submit",
        Modell: this.configuration.model.name,
        Preis: this.totalPrice,
        noninteraction: false
      });
    },
  },

And in main.js:

import VueGtm from "vue-gtm";

Vue.use(VueGtm, {
  id: "GTM-XXXXXX",
  defer: false,
  enabled: true,
  debug: false,
  loadScript: true,
  trackOnNextTick: false
});

And it worked, maybe helps someone. Thank you!

TrejoCode commented 1 year ago

Same error,