Encountering a Nuxt error where properties of null are being attempted to be read, specifically the 'addEventListener' property. As a result, both the default

Currently, I am utilizing nuxt.js along with vuesax as my UI framework. I made particular adjustments to my default.vue file located in the /layouts directory by incorporating a basic navbar template example from vuesax.
Subsequently, I employed @nuxtjs/router-extras to alter the route of "/" and direct it to /login. Furthermore, I integrated a vuesax input type template in my index.vue to test if the rendering of my /login page (navbar + input) is functioning correctly, but unfortunately, an error surfaced:

client.js?06a0:103 TypeError: Cannot read properties of null (reading 'addEventListener')
at VueComponent.handleScroll (vuesax.js?574d:24324:1)
at VueComponent.mounted (vuesax.js?574d:24382:1)
at invokeWithErrorHandling (vue.runtime.esm.js?2b0e:1863:1)
at callHook (vue.runtime.esm.js?2b0e:4235:1)
at Object.insert (vue.runtime.esm.js?2b0e:3158:1)
at invokeInsertHook (vue.runtime.esm.js?2b0e:6390:1)
at Vue.patch [as __patch__] (vue.runtime.esm.js?2b0e:6609:1)
at Vue._update (vue.runtime.esm.js?2b0e:3960:1)
at Vue.updateComponent (vue.runtime.esm.js?2b0e:4075:1)
at Watcher.get (vue.runtime.esm.js?2b0e:4495:1)

https://i.sstatic.net/gOgDf.png

As a newcomer, here are some snippets of code:

default.vue

<template>
  <div class="center examplex">
    <vs-navbar target-scroll="#padding-scroll-content" padding-scroll center-collapsed v-model="active">
      <template #left>
        <img src="" alt="">
      </template>
      <vs-navbar-item :active="active === 'wallet'" id="wallet">
        Wallet
      </vs-navbar-item>
      <vs-navbar-item :active="active === 'profil'" id="profil">
        Profil
      </vs-navbar-item>
      <template #right>
        <vs-button>Login</vs-button>
      </template>
    </vs-navbar>
    <Nuxt />
  </div>
</template>

<script>
import Vue from 'vue'
import Vuesax from 'vuesax'

import 'vuesax/dist/vuesax.css' //Vuesax styles
Vue.use(Vuesax, {
// options here
})
export default {
  name: 'DefaultLayout',
  data:() => ({
    active: 'wallet'
  })
}
</script>

index.vue

<template>
  <div class="center content-inputs">
    hello
    <vs-input
      type="password"
      v-model="value"
      label-placeholder="Password"
      :progress="getProgress"
      :visiblePassword="hasVisiblePassword"
      icon-after
      click-icon="hasVisiblePassword = !hasVisiblePassword">
      <template #icon>
        <i v-if="!hasVisiblePassword" class='bx bx-show-alt'></i>
        <i v-else class='bx bx-hide'></i>
      </template>
      <template v-if="getProgress >= 100" #message-success>
        Secure password
      </template>
    </vs-input>
  </div>
</template>

<router>
{
"path": "/login"
}
</router>

<script>
import Vue from 'vue'
import Vuesax from 'vuesax'

import 'vuesax/dist/vuesax.css' //Vuesax styles
Vue.use(Vuesax, {
// options here
})

export default {
  data:() => ({
    layout: 'default',
    value: '',
    hasVisiblePassword: false
  }),
  computed: {
    getProgress() {
      let progress = 0

      // at least one number

      if (/\d/.test(this.value)) {
        progress += 20
      }

      // at least one capital letter

      if (/(.*[A-Z].*)/.test(this.value)) {
        progress += 20
      }

      // at menons a lowercase

      if (/(.*[a-z].*)/.test(this.value)) {
        progress += 20
      }

      // more than 5 digits

      if (this.value.length >= 6) {
        progress += 20
      }

      // at least one special character

      if (/[^A-Za-z0-9]/.test(this.value)) {
        progress += 20
      }

      return progress
    }
  }
}
</script>

middleware/redirect.js

export default function(req, res, next) {
  const redirects = [
    {
      from: "/",
      to: "/login"
    }
  ]
  const redirect = redirects.find((r) => r.from === req.url)
  if (redirect) {
    res.writeHead(301, { Location: redirect.to })
    res.end()
  } else {
    next()
  }
}

Answer №1

It appears that Vuesax is no longer actively maintained, with the latest commit dating back to September 20, 2020.

This might explain why it's no longer integrated into the Nuxt CLI.

If you're just starting out, I suggest opting for a more user-friendly and well-supported framework like Vuetify, Buefy, Tailwind, or any other reliable option from the list.

https://i.sstatic.net/vVWns.png

Going straight into Nuxt without prior knowledge of Vue could pose some challenges.


To circle back to the issue at hand, while we could address specific installation problems here, we may encounter additional obstacles in the future. Given the lack of ongoing maintenance on the project, it's highly likely that we'll hit a roadblock eventually.

Expect compatibility issues with newer versions of Nuxt, such as Nuxt3. Apologies for not directly answering your question, but it's better to inform you now rather than after days of troubleshooting.


PS: If you are attempting to use res.writeHead within a client-side middleware (redirect.js), consider utilizing $router.push for redirection using the Vue router.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using Vue.js to dynamically append a bound URL

Within my Vue template, I currently have the following code: <img class="workimg" v-bind:src="item.imagemobile"> I am considering appending it to: <img class="workimg" v-bind:src="/featured/item.imagemobile"> However, this syntax seems to b ...

Troubleshooting Vue2: Unable to assign a new value to a computed property - What could be causing this

I am facing an issue with a property called romanizationSystem_FK retrieved from an API, which sometimes contains a null value. My requirement is to set the value of this property to -1 whenever it is null. To implement this logic, I attempted using a com ...

How can I utilize JQuery to dynamically refresh a dropdown menu?

My dropdown list is initially empty: <div> <label>Boarding Point </label> <select title="Select pickup city" id="boardingDropdown"> </select> </div> I am trying to popula ...

Use setTimeout and setInterval with the initial input without parentheses or double quotation marks

<!DOCTYPE HTML> <html> <head> <script type="text/javascript"> var count=0; function increaseCount(){ document.getElementById('txt').value=count; count++; setTimeout(increaseCount(),1000); } </script> </head&g ...

The element is implicitly assigned an 'any' type as the expression of type 'string' is unable to be used as an index within the type '{...}'

Trying to improve my react app with TypeScript, but encountering issues when typing certain variables. Here's the error message I'm facing: TypeScript error in /Users/SignUpFields.tsx(66,9): Element implicitly has an 'any' type becaus ...

Cannot extract the 'name' property from 'e.target' because it is not defined

I encountered an error message stating that I cannot destructure the property 'name' of 'e.target' because it is undefined within the createform() method. Despite highlighting the line causing the error, I am still unable to comprehend ...

Change the background image when hovering over an element with vanilla JavaScript by utilizing data attributes

I would like to be able to change the background image of a <div> when hovering over a link. Initially, the <div> should not have a background image when the page loads for the first time. This is my current setup: <div class="background"& ...

Combination of AngularJS and jQuery

I have a page in which additional input fields are dynamically added based on the selection made in a drop-down menu. This page is powered by angularjs, but I had to use jQuery specifically for adding these extra input fields. Here is the HTML code snippe ...

Issue with Backbone.Marionette: jQuery document.ready not executing when on a specific route

I am dealing with a situation in my web application where the document.ready() block is not being executed when the page routes from the login button to the dashboard. I have an initialize() function that contains this block, but it seems like there is an ...

The component variable fails to update after choosing an option from the select tag

Is there a way to dynamically populate a second select tag based on the selected option from the first select tag in VueJS? I am facing an issue where the variable declared in the component does not update even though the API response is correct when a cho ...

InjectableToken missing in Angular Standalone Component - Provider Not Found

In my standalone component, I am using an Injection Token to set a path (the paths are not the same for all micro-frontends). However, I do not provide this token in the component itself because I need to override it using providers in my app-module.ts. H ...

Reducing the size of a Vue project

I am currently using Vue version 2.6.10 This project was set up using Vue CLI 3, which can be found at https://cli.vuejs.org/guide/ The Vue CLI includes webpack 4 under the hood I am looking to minimize (remove all whitespaces, newlines, etc.) the source ...

How to utilize jQuery to eliminate HTML onchange code

This block of code features an HTML onchange attribute as well as the use of jQuery's change event on an input text. I want only the jQuery change event to take precedence. I have attempted to use both unbind and off without success. Can someone prov ...

Ways to resolve the error "Uncaught TypeError: data.map is not a function"

Currently developing an app using reactJS and encountering the following error in the console when using the map function: TypeError: data.map is not a function. Despite successful API data calling as confirmed by console.log, the error persists when tryin ...

Using ajax for transferring form data to a different php page

Hello everyone, I'm in need of assistance. I have a form on one PHP page and I want to use AJAX to pass the data to another PHP page that will update my database and then return the results. <form name="profile" class="profile"> < ...

How to Resolve ENOENT ERROR When Using fs.unlink in an Express.js Simple Application?

Currently, I am developing a basic blog using express.js. For managing the posts, I have opted for Typicode/lowdb as my database. The posts are created, updated, and deleted based on unique IDs stored in a data.json file. Additionally, I utilize the slug d ...

Enhancing leaflet popup functionality by incorporating ng-click into the onEachFeature function

After creating a map and connecting it with my geojson api, I encountered an issue when trying to link each marker popup with ng-click. Simply adding HTML like this did not work as expected: layer.bindPopup("<button ng-click='()'>+feature. ...

Problem with translating a variable into a selector in JQuery

When attempting to make my Jquery code more flexible, I decided to extract the selector and access it through a variable. However, despite creating variables for both selectors, neither of them seem to be functioning properly. I am confident that the issue ...

Steps to design a code editor with autocomplete dropdown using Material UI technology

I am currently working on a unique use case for my app that involves implementing an editor-like textarea with Material UI Chip components (similar to tags in an autocomplete textbox) that generate expressions. The goal is to have an autocomplete dropdown ...

Verifying data types on combined function parameters

In the process of creating a function called getLocale(obj, key, locale), I aim to retrieve a specific locale from an object based on a given key. If the desired locale variant is not available, it should return a fallback option. While adding type checki ...