Closed Venryx closed 4 years ago
This is a problem with your system or how you use trash
. Trash is working fine for normal Node.js usage. Trash uses the correct absolute path to the binaries: https://github.com/sindresorhus/trash/blob/d6d2c3a86125925b4e04749a8e3a311af48e93b8/lib/macos.js#L11
Oh I see what happened. I use webpack to bundle the code for my program, and it was bundling the trash
library's code into the same bundle, which was in the Dist
folder.
I was able to fix it (properly) by adding this to my webpack config:
webpackConfig.externals.trash = "commonjs trash";
Just coming here to mention that I had the same problem (where the trash
library's code was bundled with other packages and went to the wrong folder) and making a similar change in the webpack config file fixed my issue. Thanks to you both for your comments in this issue thread.
Title. I expected the library to automatically locate the binary files for the given platform, but instead it simply searches the working directory for the binaries. (requiring manual copying/distribution-alongside)
If you don't do so, you get this error (added for searches):
I ended up solving it by calling the below before using the library:
Even if a specific solution like the above is not included, it would be nice at least for the readme to mention that this step is necessary, and maybe offering a suggestion on how to do so.
PS. This library is trash. (ie. helpful 🤣)