The error message is indicating that the property `match` is being attempted on an undefined object. This issue is puzzling as it does not reference any specific files or

I encountered an issue while working on my project: I kept receiving the error message "Cannot read property match of undefined."

Cannot read property 'match' of undefined

The error points to a specific line in polyfills.js:

process.version.match

This error is perplexing as it doesn't specify any particular file. Could someone please take a look at this github repo for me?

https://github.com/raphael10-collab/ElectronVueTypeScriptScaffolding

Update 1)

Thanks to Elias comment, I realized that vue.config.js was messed-up. Now vue.config.is is :

// https://nklayman.github.io/vue-cli-plugin-electron-builder/guide 
/guide.html#web-workers
const WorkerPlugin = require('worker-plugin')

module.exports = {
  // options...
  publicPath: '',
  pluginOptions: {
    electronBuilder: {

      // Other configuration options...

      nodeIntegration: true

    },
    
    configureWebpack: {
      plugins: [new WorkerPlugin()]
    }
  }
}

Regarding nodeIntegration, I disabled it in /src/background.js because I read it is more secure to have preload.js file

This is my new webpack.config.js (it was messed up as well, like vue.config.is, with each module.exports overriding the previous one):

module.exports = {
  entry: './src/background.js',
  
  // Other webpack configurations...

}

I do not understand what should I enable here in webpack: https://webpack.js.org/plugins/define-plugin/

Update 2)

I disabled nodeIntegration in vue.config.js

vue.config.js :

// More configurations...

      nodeIntegration: false
    },

    configureWebpack: {
      plugins: [new WorkerPlugin()]
    }
  }
}

and defined process in webpack.config.js

webpack.config.js :

module.exports = {
  entry: './src/background.ts',

  // Other webpack configurations...

  new webpack.DefinePlugin({
    'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV)
  })
}

When running yarn electron:serve I now get Error: Cannot read property 'match' of undefined

https://i.sstatic.net/4CR5S.png

If I keep nodeIntegration:true in vue.config.js and change in src/background.js to :

// Code snippet...

when running yarn electron:serve I get this error:
"Cannot read property 'app' of undefined"</p>
<p><a href="https://i.sstatic.net/KzSdB.png" rel="nofollow noreferrer"></a></p>
<p>This is /src/store/modules/app.ts :</p>
<pre><code>import Vue from 'vue'

// Other code snippets...

export default app

But I would prefer to solve the problem while keeping nodeIntegration: false in order to keep the app safer

Update 3) I discovered that the problem "Cannot read property match of undefined" disappears once I comment this line

// Code snippet...

in src/background.ts :</p>
<pre><code>// Code snippet...

and db.get('settings.currentTheme') comes from this file:

src/services/electron-services/database/index.ts :

// Large code snippet...

Answer №1

It seems like the issue lies with your vue.config.js file, which is only exporting the final object and overriding any previous exports.

Another potential problem could be that you have disabled nodeIntegration, resulting in process being undefined unless you activate webpack's definition feature.

Update: In order to use require in the renderer, you will need to enable nodeIntegration in your background.ts file or disable it in your vue.config.js.

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

React and Express are two powerful technologies that work seamlessly

Here lies the contents of the mighty index.html file <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <script src="https://cdnjs.cloudflare/ajax/libs/babel-core/5.8.23/browser.min.js"></script> <s ...

"Effortlessly Arrange Multiple Gridview Rows Using Checkbox Selection in jQuery Drag and Drop

Struggling with getting checkboxes clicked when a GridViewRow becomes selected. Utilizing jQuery Methods like .sortable and .selectable. Worked as intended but looking to have a checkmark placed on the checkbox cbBulkSort within the GridView's first c ...

In Angular 4, I encountered an issue where adjusting the height of the navigation bar caused the toggle button to no longer expand the menu in Bootstrap

In the process of developing an angular application, I encountered a situation where I needed to adjust the height of the nav bar using style properties. After making the necessary changes, everything was working fine. However, a problem arose when I mini ...

Steps for linking a keypress to trigger a specific action

I need help creating a script that will redirect to a URL when a button is clicked. Below is the code I have developed. HTML : <a id="#next" href="example.com">↵</a> <a id="#previous" href="example.com">↳</a> JS : $(document ...

Having trouble with npm global installation? Encountering the error message "Error: EACCES: permission denied

As the administrator of my MacBook, I am facing an issue while trying to run a npm command in my Django project. It is refusing to run due to missing permissions. (venv) jonas@Air-von-Jonas salaryx % npm install -g sass npm ERR! code EACCES npm ERR! syscal ...

Converting a string into an array of JSON objects

I am currently attempting to send data to my NodeJS server using the HTTP protocol (vue-resource). The goal is to send an array of JSON objects structured like this : [{"name":"Charlotte","surname":"Chacha","birth":"2000-04-02"},{"name":"Michael","surname ...

Laravel throws an error message "expression expected" when trying to use the @

I keep encountering an issue when attempting to pass a variable from PHP code to JavaScript. Expression expected Here is the code snippet I am using in Laravel 7.0 : <script> let variable = @json($array); </script> Although the code still ...

When I attempted to run `npm start`, an error with status code 1 was thrown,

Upon running npm start, the following error is displayed: > <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2d4c5d5d6d1d031c031d">[email protected]</a> start /Users/user/Desktop/react-tutorial > react-script ...

Suggestions for changing sub-component data in Vue

I have a scenario where I am using a component with tabs inside. The Head component (parent) includes the following code: <v-btn @click="setSelectedTab('Set') "> ... <component :is="selectedTab"></component> ...

Display resize grip when hovering

Is there a way to make elements resizable using resize: both, but only show the corner handle when hovering over the element? https://i.sstatic.net/cGIYf.png I am looking for a solution to display that specific handle only on hover. ...

When the user clicks, display one div and conceal the others

https://codepen.io/leiacarts/pen/PoqRxNZ I need assistance with two specific tasks related to my website layout. Firstly, I am struggling to ensure that images displayed in the red sections remain constrained and automatically resize within the content di ...

The error message "Type 'IPromise<{}>' is not compatible with type 'IPromise<TemplatesPagingModel>' in typescript version 2.8.0" is displayed

Currently, I am working on an AngularJS framework (version 1.5.8) with the latest TypeScript files (version 2.8.0). However, after updating to the most recent TypeScript version, the code below is not compiling. Implementation of Angular interface: inter ...

Can you explain the role of the %GetOptimizationStatus function within a JavaScript file executing in Node.js?

Currently, I am delving into an article that discusses optimization strategies and includes the following code snippet: //Function that contains the pattern to be inspected (using an `eval` statement) function exampleFunction() { return 3; eval(&a ...

Using JavaScript to find the weekday of the same date next year

Struggling to determine the weekday of a particular date next year? Take for example Tuesday, April 19, 2016 as the given date. What we need to calculate is: TUESDAY, April 18, 2017. Consistency with weekdays is crucial in this scenario. The challenge lie ...

Disable the outer div scrolling in VueJS, but re-enable it once the inner div has reached the bottom of

I am currently working on a webpage that contains multiple divs stacked vertically. Here is the concept I am working with: Once the scrollbar reaches the bottom of the first div, the outer scrollbar will be disabled and the inner scrollbar will be enabled ...

ReactPlayer allows for the simultaneous playback of two files

I am trying to simultaneously play two files in reactjs using ReactPlayer. The first file is a video music clip that includes human voice audio, while the second file is music only without the human voice. My issue is that when I run the code provided, ei ...

Vuetify navigation drawer within a v-card experiencing functionality issues

Struggling to integrate a navigation panel into the v-card. Oddly, when adding the navigation drawer, it seems to be pushing everything within the v-card downward and out of the card. <v-card flat outlined> <v-navigation-drawer v-model=& ...

CSS struggles after implementing conditional checks in return statement for an unordered list

I'm encountering a CSS issue with the header section. When I include the following code snippet in my code to display a tab based on a condition, the entire header list doesn't appear in a single horizontal line: <div> {isAdmin(user) ? ...

Troubles emerge when incorporating the AOS library into main.js in Vue 3

Hey there! I'm currently incorporating the Aos library into my Vue 3 project and encountering issues. import App from './App.vue' import AOS from 'aos' import 'aos/dist/aos.css' import { createApp } from "vue" ...

Leveraging Multiple MongoDB Databases in Meteor.js

Can 2 Meteor.Collections fetch data from separate MongoDB database servers? Dogs = Meteor.Collection('dogs') // mongodb://192.168.1.123:27017/dogs Cats = Meteor.Collection('cats') // mongodb://192.168.1.124:27017/cats ...