Cannot read property 'end' of null
See original GitHub issueBug Report
Current Behavior
I’m getting the following error when trying to minify a large file outputted by TypeScript.
TypeError: dist/main.js: Cannot read property 'end' of null
at _evaluate (node_modules/babel-traverse/lib/path/evaluation.js:160:58)
at evaluate (node_modules/babel-traverse/lib/path/evaluation.js:65:17)
at NodePath.evaluate (node_modules/babel-traverse/lib/path/evaluation.js:41:15)
at evaluateIdentifier (node_modules/babel-helper-evaluate-path/lib/index.js:127:15)
at evaluate (node_modules/babel-helper-evaluate-path/lib/index.js:19:12)
at PluginPass.Expression (node_modules/babel-plugin-minify-constant-folding/lib/index.js:165:21)
at PluginPass.newFn (node_modules/babel-traverse/lib/visitors.js:318:17)
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)
I’ve tracked it down to #4875 which introduces an if statement that compares path.node.start
with binding.path.node.end
. Note that one side is comparing a property on path
, and the other on binding.path
.
Changing the right-hand side to path.node.end
seems to fix the issue.
Input Code Unfortunately, I discovered this in a closed source repo…
Expected behavior/code I expected the file to be minified and translated to ES2015.
Babel Configuration (.babelrc, package.json, cli command)
{
"presets": ["es2015", "minify"],
"comments": false
}
babel dist/main.js --out-file dist/main.min.js
Environment
- Babel version(s): 6.26.0 (babel-core 6.26.0)
- Node/npm version: Node v10.0.0, npm v5.6.0
- OS: macOS 10.13.4
- Monorepo: no
- How you are using Babel:
cli
Possible Solution
diff --git a/node_modules/babel-traverse/lib/path/evaluation.js b/node_modules/babel-traverse/lib/path/evaluation.js
index d608418..c05b833 100644
--- a/node_modules/babel-traverse/lib/path/evaluation.js
+++ b/node_modules/babel-traverse/lib/path/evaluation.js
@@ -156,7 +156,7 @@ function evaluate() {
return deopt(binding.path);
}
- if (binding && path.node.start < binding.path.node.end) {
+ if (binding && path.node.start < path.node.end) {
return deopt(binding.path);
}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:9 (4 by maintainers)
Top Results From Across the Web
Getting "Cannot read property 'pickAlgorithm' of null" error in ...
Running npm cache clear --force. Environment: OS: Windows 10 react native: 0.65.1. Node: 14.17.4 npm: 7.21.0.
Read more >Uncaught TypeError: Cannot read property of null - iDiallo
This error occurs when you read a property or call a method on a null object . That's because the DOM API returns...
Read more >Uncaught TypeError: Cannot read property 'end' of null / range ...
Uncaught TypeError : Cannot read property 'end' of null / range is null. Open, Needs TriagePublic. Actions.
Read more >Uncaught TypeError: Cannot read property of undefined In
This error occurs in Chrome Browser when you read a property or call a method on an undefined object . There are a...
Read more >Client Exception Uncaught TypeError: Cannot read property ...
Client Exception Uncaught TypeError : Cannot read property 'getFieldType' of null - when editing or creating new item. FootPrints ...
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
I was running into the same issue and I managed to fix it by changing my
babel-preset-minify
version from0.5.0
->0.3.0
.babelrc
package.json
$ npm run builld:dist