0
i am taking a course that uses Electron 5.0.13, and is giving that error in the terminal of my application in Electron
Uncaught ReferenceError: __dirname is not defined
at eval (index.js?bdb9:4)
at Object../node_modules/electron/index.js (chunk-vendors.js:2080)
at __webpack_require__ (app.js:849)
at fn (app.js:151)
at eval (cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/components/Home.vue?vue&type=script&lang=js&:2)
at Module../node_modules/cache-loader/dist/cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/components/Home.vue?vue&type=script&lang=js& (app.js:950)
at __webpack_require__ (app.js:849)
at fn (app.js:151)
at eval (Home.vue?59e2:1)
at Module../src/components/Home.vue?vue&type=script&lang=js& (app.js:1113)
I was using Electron 9.0 and came across this error in the course had someone who asked and the teacher answered that was to put Electron 5.0.13, that’s what I did, but n solved, already removed Yarn-lock and node_modules several times and did not solve.
Here is the code
<script src="https://electron.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<template>
<v-content fluid>
<v-form>
<v-file-input multiple chips v-model="files" append-icon="mdi-send"
label="Selecione um Legenda" prepend-icon="mdi-message-text"
@click:append="processSubtitles"/>
</v-form>
<div class="pills">
<Pill v-for="word in groupedWords" :key="word.name"
:name="word.name" :amount="word.amount"/>
</div>
</v-content>
</template>
<script>
import { ipcRenderer } from 'electron'
import Pill from './pill.vue'
export default {
components: { Pill },
data: function() {
return {
files: [],
groupedWords: [
{ name: 'i', amount: 1234 },
{ name: 'you', amount: 900 },
{ name: 'he', amount: 853 }
]
}
},
methods: {
processSubtitles() {
console.log(this.files)
ipcRenderer.send('blabla', 'ping')
ipcRenderer.on('blabla', (event, resp) => {
console.log(resp)
})
}
}
}
</script>
When you created Browserwindow, you set the webPreferences.nodeIntegration flag to true?
– Gomiero
I didn’t say no, I was just doing
– Lucas Neves
That’s probably the problem. When you create Browserwindow, you need to set this flag to true, because the error appears to be in Vue. However, before setting this flag, I recommend reading the documentation and evaluating if your application will not have any security risk.
– Gomiero