IT:AD:npm:HowTo:Deal With Long Filenames
- See also:
Summary
Npm packages download dependency packages, which in turn download dependency packages…and sooner or later you end up with deeply nested directories.
And then you try to delete them…and you get errors all over the place similar to the following:
node_modules\gulp-watch\node_modules\gulp-util\node_modules\dateformat\node_modules\meow\node_modules\read-pkg-up\node_modules\read-pkg\node_modules\load-json-file\node_modules\parse-json\node_modules\error-ex\node_modules\is-arrayish\.istanbul.yml - The file name is too long.
The issue is that Windows has a max of 260 char for filenames. And they'll never change it. So you are going to have to work around it.
Options
Use 7Zip
Know that 7Zip can delete long file names…but although that's really useful to know, it won't help you much with npm issues.
Map Drives
It's been mentioned that you can map directories to shorten the directory:
subst x: \path\to\long\folderTrue…but it's not going to fix everything, and what a pain to have to do that…
Use NPM
Turns out that if nothing is going to fix it – every – there are only two things you can do.
- For IT:AD:DropBox and IT:AD:OneDrive…never going to work with NPM. And it never was a good idea in the first place. Get over it. Use Git.
- For removing packages, don't use
rmor other IT:AD:CLI commands – use IT:AD:NPM's `uninstall command, as it's capable of handling long file names using the same tricks as 7Zip: