`path.remove` sometimes throws
See original GitHub issueWe should probably address this in Babel, but I’m occasionally running into cases of path.remove()
throwing error about context:
Here’s an example from trying to run Nuclide codebase through Babili:
➜ Nuclide ./scripts/dev/release_transpile.js
7 workers. 1863 files...
Error transpiling "/Users/kangax/fbsource/fbobjc/Tools/Nuclide/pkg/fb-biggrep-cli/lib/biggrep.js"
/Users/kangax/fbsource/fbobjc/Tools/Nuclide/pkg/nuclide-node-transpiler/lib/NodeTranspiler.js:203
throw err;
^
TypeError: unknown: Property consequent of ConditionalExpression expected node to be of a type ["Expression"] but instead got null
at Object.validate (/Users/kangax/fbsource/fbobjc/Tools/Nuclide/node_modules/babel-types/lib/definitions/index.js:109:13)
at Object.validate (/Users/kangax/fbsource/fbobjc/Tools/Nuclide/node_modules/babel-types/lib/index.js:511:9)
at NodePath._replaceWith (/Users/kangax/fbsource/fbobjc/Tools/Nuclide/node_modules/babel-traverse/lib/path/replacement.js:176:7)
at NodePath._remove (/Users/kangax/fbsource/fbobjc/Tools/Nuclide/node_modules/babel-traverse/lib/path/removal.js:58:10)
at NodePath.remove (/Users/kangax/fbsource/fbobjc/Tools/Nuclide/node_modules/babel-traverse/lib/path/removal.js:30:8)
at PluginPass.CallExpression (/Users/kangax/fbsource/fbobjc/Tools/Nuclide/node_modules/babel-plugin-transform-remove-console/lib/index.js:10:16)
at newFn (/Users/kangax/fbsource/fbobjc/Tools/Nuclide/node_modules/babel-traverse/lib/visitors.js:276:21)
at NodePath._call (/Users/kangax/fbsource/fbobjc/Tools/Nuclide/node_modules/babel-traverse/lib/path/context.js:76:18)
at NodePath.call (/Users/kangax/fbsource/fbobjc/Tools/Nuclide/node_modules/babel-traverse/lib/path/context.js:48:17)
at NodePath.visit (/Users/kangax/fbsource/fbobjc/Tools/Nuclide/node_modules/babel-traverse/lib/path/context.js:105:12)
I narrowed it down to a combination of simplify and remove-console plugins, but there might be something else. The source code doesn’t have anything unusual; just few expressions with console.log
and console.error
.
Temporary solution could be to wrap path.remove()
in try/catch. Ideal one would be to find out what’s causing this and fix it in Babel.
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
c# - Cannot delete directory with Directory.Delete(path, true)
I'm not surprised that the method sometimes throws, but I'm surprised to get this particular message when recursive is true. (I know the...
Read more >Filescripting object .delete - path not found (sometimes)
This works for 99% of the folders i am trying to clear, but occasionally i get the following. Path = \\MYSERVER\images$\Zerotouch\Migration\ ...
Read more >Path Operations - Essential Java Classes - Oracle Help Center
This method throws an exception if the file does not exist or cannot be accessed. You can catch the exception when you want...
Read more >How to delete a file in Windows with a too long filename?
When you want to completely delete a directory and it contains long paths, robocopy does a VERY good job: mkdir empty_dir robocopy empty_dir ......
Read more >How to delete a file in Java - Mkyong.com
1.1 The Files.delete(Path) deletes a file, returns nothing, or throws an exception if it fails. DeleteFile1.java. package ...
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
It seems in a lot of cases
console.log
cannot just simply be removed but would rather need to be replaced by something.In the example I replaced it with undefined.
http://astexplorer.net/#/G38YR5EEES/2
Maybe this is broken.
Interestingly if i do:
it turns correctly into: