[BUG] Cannot read property 'add' of undefined
See original GitHub issueHere’s my .babelrc
:
babelrc
{
"presets": [
"es2015", "stage-2", "stage-0", "react", "es2015-ie"
],
"plugins": [
"transform-runtime", "transform-decorators-legacy", "transform-class-properties"
],
"compact": true,
"env": {
"test": {
"plugins": ["istanbul"]
},
"production": {
"presets": [
"babili"
]
}
}
}
Running babel resulted in this error:
ERROR in ./src/components/Main/index.js
Module build failed: TypeError: /src/components/Main/index.js: Cannot read property 'add' of undefined
at ScopeTracker.addReference (/node_modules/babel-plugin-minify-mangle-names/lib/scope-tracker.js:55:36)
at ReferencedIdentifier (/node_modules/babel-plugin-minify-mangle-names/lib/index.js:190:28)
at newFn (/node_modules/babel-traverse/lib/visitors.js:318:17)
at bfsTraverse (/node_modules/babel-plugin-minify-mangle-names/lib/bfs-traverse.js:34:43)
at Mangler.collect (/node_modules/babel-plugin-minify-mangle-names/lib/index.js:269:9)
at Mangler.run (/node_modules/babel-plugin-minify-mangle-names/lib/index.js:70:14)
at PluginPass.exit (/node_modules/babel-plugin-minify-mangle-names/lib/index.js:589:19)
at newFn (/node_modules/babel-traverse/lib/visitors.js:276:21)
at NodePath._call (/node_modules/babel-traverse/lib/path/context.js:76:18)
at NodePath.call (/node_modules/babel-traverse/lib/path/context.js:48:17)
at NodePath.visit (/node_modules/babel-traverse/lib/path/context.js:117:8)
at TraversalContext.visitQueue (/node_modules/babel-traverse/lib/context.js:150:16)
at TraversalContext.visitSingle (/node_modules/babel-traverse/lib/context.js:108:19)
at TraversalContext.visit (/node_modules/babel-traverse/lib/context.js:192:19)
at Function.traverse.node (/node_modules/babel-traverse/lib/index.js:114:17)
at traverse (/node_modules/babel-traverse/lib/index.js:79:12)
at File.transform (/node_modules/babel-core/lib/transformation/file/index.js:548:35)
at /node_modules/babel-core/lib/transformation/pipeline.js:50:19
at File.wrap (/node_modules/babel-core/lib/transformation/file/index.js:564:16)
at Pipeline.transform (/node_modules/babel-core/lib/transformation/pipeline.js:47:17)
at transpile (/node_modules/babel-loader/lib/index.js:46:20)
at Object.module.exports (/node_modules/babel-loader/lib/index.js:163:20)
@ ./src/dist.js 1:127-153
Now if I disable Mangling, the minification doesn’t seem to have much effect:
npm run dist
> BABEL_ENV=production webpack --env=dist
Hash: b6d52d6cc9478801536d
Version: webpack 1.15.0
Time: 4355ms
Asset Size Chunks Chunk Names
dist.js 749 kB 0 [emitted] main
dist.js.map 923 kB 0 [emitted] main
+ 340 hidden modules
Dist without production
env:
> webpack --env=dist
Hash: 8636992c125a9a4e5f8a
Version: webpack 1.15.0
Time: 3934ms
Asset Size Chunks Chunk Names
dist.js 752 kB 0 [emitted] main
dist.js.map 925 kB 0 [emitted] main
+ 340 hidden modules
Issue Analytics
- State:
- Created 6 years ago
- Reactions:51
- Comments:54 (5 by maintainers)
Top Results From Across the Web
Error: Cannot read property "add" of undefined · Issue #19
Basically, this.$el or that.$refs['app-navbar-id'] seem to be undefined, so it is trying to add classes to a classList of an undefined element.
Read more >TypeError: Cannot read property 'add' of undefined Discord.js ...
So, I am making a bot and here's a part of my code what has a problem:
Read more >Uncaught TypeError: Cannot read property 'add' of undefined
In the Console i get an Error caused by WPForms. The Error states: Uncaught TypeError: Cannot read property 'add' of undefined. The page...
Read more >Uncaught TypeError : Cannot read properties of undefined
Looking for ways to handle Uncaught TypeError: Cannot read property of undefined in JavaScript? This guide will help you to catch errors.
Read more >Uncaught TypeError: Cannot read property '1' of undefined
This error is because there is a property field in that model, on that form that doesn't have his generic value defined, probably...
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
After upgrading babel to latest version I am still experiencing this issue
For me works with this configuration only: