Syntax Error: TypeError: Cannot read properties of undefined (reading 'spaces') npm run serve vue

Viewed 45

Hi i'm facing somewhat a strange problem during $npm run serve

enter image description here

here is my page structure

<template>
  <div>
    ...
  </div>
</template>

<script>
export default {
   name: 'game',
   ...
}
</script>

<style lang="scss" scoped>
 $variable1:#fff;
 ....
</style>

My package.json looks something like this

"devDependencies":{
    "node-sass": "^6.0.0",
    "sass-loader": "^10.1.0",
    "vue-loader-v16": "npm:vue-loader@^16.1.1"
}
1 Answers

Generally this kind of error happens when you try to access a property of an object that does not (yet) exist.

So I think somewhere in your code you try to access someObject.spaces but someObject is undefined. To avoid this, you can add a simple if-clause before your operation:

if(someObject){
  doSomething(someObject.spaces)
}

I think you'll have to fill in more code to identify exactly what happens, though.

Related