baklavajs icon indicating copy to clipboard operation
baklavajs copied to clipboard

Nuxt window is not defined

Open fathi91 opened this issue 3 years ago • 9 comments

Hi, i followed the steps of how to use baklavajs with Nuxtjs from the doc url 'https://mrambourg.medium.com/use-baklavajs-with-nuxt-ba696c2a1602'

but the first thing i got is window is not defined what do i do?

fathi91 avatar Dec 13 '21 15:12 fathi91

Hi, When do you have an error message (step number) ? Can you copy this message ?

Le lun. 13 déc. 2021 à 16:40, fathi91 @.***> a écrit :

Hi, i followed the steps of how to use baklavajs with Nuxtjs from the doc url ' https://mrambourg.medium.com/use-baklavajs-with-nuxt-ba696c2a1602'

but the first thing i got is window is not defined what do i do?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/newcat/baklavajs/issues/170, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANP64PVEQVIBAZANQ2CXW3UQYHVTANCNFSM5J6OTXWQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

ramamama avatar Dec 13 '21 15:12 ramamama

i get this error after the first dev server run on Step 7 this is a screenshot of the error

Screenshot 2021-12-13 180736

fathi91 avatar Dec 13 '21 16:12 fathi91

This is a webpack error. It's why in the fourth step you have to change nuxt.config.js build part and add babel plugins. Could you check your nuxt.config.js and verify that babel plugin is in.

Le lun. 13 déc. 2021 à 17:13, fathi91 @.***> a écrit :

i get this error after the first dev server run this is a screenshot of the error

[image: Screenshot 2021-12-13 180736] https://user-images.githubusercontent.com/71710650/145847688-4fcaa7d5-3c89-4e22-962f-acc124673c1a.jpg

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/newcat/baklavajs/issues/170#issuecomment-992634966, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANP64KYDMWYFDDZC7E3D6LUQYLTBANCNFSM5J6OTXWQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

ramamama avatar Dec 13 '21 18:12 ramamama

this is the config file

export default {
  // Global page headers: https://go.nuxtjs.dev/config-head
  head: {
    title: 'builder',
    htmlAttrs: {
      lang: 'en'
    },
    meta: [
      { charset: 'utf-8' },
      { name: 'viewport', content: 'width=device-width, initial-scale=1' },
      { hid: 'description', name: 'description', content: '' },
      { name: 'format-detection', content: 'telephone=no' }
    ],
    link: [
      { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' }
    ]
  },

  // Global CSS: https://go.nuxtjs.dev/config-css
  css: [
  ],

  // Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins
  plugins: [
   {src: '@/plugins/baklava.client.js', ssr: false}
  ],

  // Auto import components: https://go.nuxtjs.dev/config-components
  components: true,

  // Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules
  buildModules: [
    // https://go.nuxtjs.dev/typescript
    '@nuxt/typescript-build',
  ],

  // Modules: https://go.nuxtjs.dev/config-modules
  modules: [
    // https://go.nuxtjs.dev/axios
    '@nuxtjs/axios',
  ],

  // Axios module configuration: https://go.nuxtjs.dev/config-axios
  axios: {},

  // Build Configuration: https://go.nuxtjs.dev/config-build
  build: {
    babel: {
      plugins: [
        ['@babel/plugin-proposal-private-methods', { loose: true }]
      ]
    }
  }
}

and this is the dependencies in package.json

"dependencies": {
    "@babel/plugin-proposal-private-methods": "^7.16.0",
    "@nuxtjs/axios": "^5.13.6",
    "baklavajs": "^1.9.2",
    "core-js": "^3.15.1",
    "nuxt": "^2.15.7"}

i don't think that i missed i'm not sure why this is happen

fathi91 avatar Dec 13 '21 19:12 fathi91

Ok, I reproduce the same error. I will search for a solution and let you know when i'll find it.

Le lun. 13 déc. 2021 à 20:26, fathi91 @.***> a écrit :

this is the config file

export default { // Global page headers: https://go.nuxtjs.dev/config-head head: { title: 'builder', htmlAttrs: { lang: 'en' }, meta: [ { charset: 'utf-8' }, { name: 'viewport', content: 'width=device-width, initial-scale=1' }, { hid: 'description', name: 'description', content: '' }, { name: 'format-detection', content: 'telephone=no' } ], link: [ { rel: 'icon', type: 'image/x-icon', href: '/favicon.ico' } ] },

// Global CSS: https://go.nuxtjs.dev/config-css css: [ ],

// Plugins to run before rendering page: https://go.nuxtjs.dev/config-plugins plugins: [ {src: '@/plugins/baklava.client.js', ssr: false} ],

// Auto import components: https://go.nuxtjs.dev/config-components components: true,

// Modules for dev and build (recommended): https://go.nuxtjs.dev/config-modules buildModules: [ // https://go.nuxtjs.dev/typescript @.***/typescript-build', ],

// Modules: https://go.nuxtjs.dev/config-modules modules: [ // https://go.nuxtjs.dev/axios @.***/axios', ],

// Axios module configuration: https://go.nuxtjs.dev/config-axios axios: {},

// Build Configuration: https://go.nuxtjs.dev/config-build build: { babel: { plugins: [ @.***/plugin-proposal-private-methods', { loose: true }] ] } }}

and this is the dependencies in package.json

"dependencies": { @./plugin-proposal-private-methods": "^7.16.0", @./axios": "^5.13.6", "baklavajs": "^1.9.2", "core-js": "^3.15.1", "nuxt": "^2.15.7"}

i don't think that i missed i'm not sure why this is happen

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/newcat/baklavajs/issues/170#issuecomment-992797909, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANP64PYZ6SVBE5KCW2KWNLUQZCIHANCNFSM5J6OTXWQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

ramamama avatar Dec 13 '21 20:12 ramamama

Are there any updates on this issue? Ran into the same problem.

Zendrex avatar Feb 28 '22 21:02 Zendrex

I was able to solve this problem by adding the following items to nuxt.config.ts. This is a phenomenon that can be seen when using a library that does not support SSR. Set SSR to False on Pages that use this library.

export default ({
  routeRules: {
    '/': { ssr: false },
  }
})

SohMitian avatar Apr 10 '23 13:04 SohMitian

If Nuxt3 is alright, I will share a repository that has been confirmed to work as a reference. Nuxt3-Baklavajs

SohMitian avatar Apr 10 '23 14:04 SohMitian

I don't have a problem and I haven't added any configuration to the nuxt.config.ts file for nuxt3.9.1. This problem may have been solved.

starker-xp avatar Jan 07 '24 09:01 starker-xp