Uncaught ReferenceError: exports is not defined
See original GitHub issue💬 Questions and Help
Hi, when I try to print out the extracted scripts(getScriptTags) on the server i receive those errors in the console : Uncaught ReferenceError: exports is not defined
The code in those files starts with :
exports.ids = ["components-Home"];
exports.modules = {
My webpack config on the server looks like this :
...
module.exports = {
devtool: isDev ? 'inline-source-map' : false,
entry: [
'./server/index.js'
],
externals: [],
target: 'node',
output: {
path: path.join(__dirname, outputDirectory),
filename: 'bundle.js',
publicPath: '/',
},
mode: isDev ? 'development' : 'production',
resolve: {
extensions: [".js", ".jsx", ".json"]
},
plugins: [
new CleanWebpackPlugin(outputDirectory),
new LoadablePlugin(),
],
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
},
},
{
test: /\.jsx$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader'
}
},
{
test: /\.css$/,
use: [
{
loader: MiniCssExtractPlugin.loader,
options: {
publicPath: '../'
}
},
"css-loader"
]
},
{
test: /\.(png|woff|woff2|eot|ttf|svg)$/,
use: [
{
loader: 'url-loader',
options: {
limit: 8192,
name: 'static/[hash]-[name].[ext]',
publicPath: '../'
}
}
]
}
]
}
}
if(isDev) {
module.exports.entry.push('webpack/hot/poll?1000')
module.exports.externals.push(nodeExternals({ whitelist: ['webpack/hot/poll?1000'] }))
module.exports.plugins.push(
new webpack.NamedModulesPlugin(),
new webpack.HotModuleReplacementPlugin(),
new webpack.NoEmitOnErrorsPlugin(),
new WebpackShellPlugin({
onBuildStart:['echo "Webpack Start"'],
onBuildEnd:['node ' + path.join(__dirname, outputDirectory) + '/' + 'bundle.js']
}),
)
} else {
module.exports.externals.push(nodeExternals())
}
Anyone knows whats going on here ?
Issue Analytics
- State:
- Created 4 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Typescript ReferenceError: exports is not defined
Trying to implement a module following the official handbook, I get this error message: Uncaught ReferenceError: exports ...
Read more >How to fix ReferenceError: exports is not defined TypeScript
If you are getting the error for code that runs in the browser, try defining a global exports variable above the script tags...
Read more >Uncaught ReferenceError: exports is not defined : r/typescript
Getting this error for some dumb reason i'm sure. Uncaught ReferenceError: exports is not defined. at app.js:2. (anonymous) @ app.js:2. all ...
Read more >exports is not defined" in browser : WEB-26773
Typescript compiler outputs wrong javascript module format, giving "ReferenceError: exports is not defined" in browser ; "use strict"; Object.defineProperty ...
Read more >visual studio typescript "Uncaught ReferenceError: exports is ...
HTML : visual studio typescript " Uncaught ReferenceError: exports is not defined at.
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 FreeTop 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
Top GitHub Comments
@ischoe I’m running into this same issue, can you share the changes you made in your Webpack config?
Hi @ischoe I have the same issue. Can you tell me what you’ve changed?