Electron Webpack Error: Uncaught ReferenceError: require is not defined
See original GitHub issueI have a very simple setup with electron and webpack. I’m trying to use the target electron-renderer but seems I cannot load electron in the app js file (electron-renderer process). I suspect it has something to do with the correct webpack config setup.
I keep getting this error: Uncaught ReferenceError: require is not defined
Lib versions: webpack: 1.13.1 electron-prebuilt: 1.2.0
Here is my app repository: https://github.com/Cecildt/electron-webpack
Here is my webpack.config.js details:
var path = require('path');
var webpack = require('webpack');
var CommonsChunkPlugin = webpack.optimize.CommonsChunkPlugin;
module.exports = {
devtool: 'source-map',
debug: true,
entry: {
'app': './src/index.ts'
},
output: {
path: __dirname + '/build/',
publicPath: 'build/',
filename: '[name].js',
sourceMapFilename: '[name].js.map',
chunkFilename: '[id].chunk.js'
},
resolve: {
extensions: ['','.ts','.js','.json', '.css', '.html'],
modulesDirectories: ['node_modules']
},
module: {
loaders: [
{
test: /\.ts$/,
loader: 'ts',
exclude: [ /node_modules/, /releases/ ]
},
{
test: /\.json$/,
loader: 'json'
},
{
test: /\.(css|html)$/,
loader: 'raw'
},
{
test: /\.(png|jpg)$/,
loader: 'url?limit=10000'
}
]
},
plugins: [
new webpack.ExternalsPlugin('commonjs', ['electron'])
],
externals: [
],
target:'electron-renderer'
};
Hope somebody can help me! Thanks in advance.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:12
- Comments:8 (1 by maintainers)
Top Results From Across the Web
Electron Webpack `require is not defined` - Github-Gist
If you're using Webpack to bundle your Electron app and you're getting require is not defined , and you don't want to set...
Read more >'Require is not defined' when adding electron-renderer to ...
I understand that adding the following line to my Webpack config would allow me to import electron on the renderer side. module.exports =...
Read more >How to solve require is not defined in electronjs - YouTube
How to solve require is not defined in electron js ?Solution:I have solved this issue by updating ElectronJs VersionLet Update it to the ......
Read more >electron 5.0.0 "Uncaught ReferenceError: require is not defined"
JavaScript : electron 5.0.0 " Uncaught ReferenceError : require is not defined " [ Gift : Animated Search Engine : https://bit.ly/AnimSearch ] ...
Read more >webpack require is not defined | The Search Engine You Control
So just remove it to fix error. Open side panel. Webpack: Uncaught ReferenceError: require is not defined. Asked Oct 1, 2018 • 4...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
+1.
+1