The `webdav` library provides a promise-based WebDAV client for interacting with remote filesystems, supporting both Node.js and browser environments. Currently at version 5.9.0, the library is under active development, with version 4 in maintenance mode until January 2025, and earlier versions deprecated. It differentiates itself by prioritizing an easy-to-consume client API for common WebDAV services (like Nextcloud, ownCloud, Box, Yandex) over strict RFC adherence. Version 5 transitioned to ECMAScript Modules (ESM) and uses `@buttercup/fetch` for requests, replacing Axios from prior versions. This enables cross-platform compatibility, leveraging native `fetch` in browsers and `node-fetch` in Node.js, making it suitable for modern JavaScript projects.
npm install webdavVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize a WebDAV client, list directory contents, create a directory, upload a file, download it, and finally clean up the created resources.
Migrate your project to use ES Modules (e.g., add `'type': 'module'` to `package.json` and use `import` statements) or use an earlier `webdav` version (4.x or below) which supports CommonJS.
Update any code that directly interacted with Axios-specific features or expected Axios-shaped error objects. Ensure your environment correctly handles `fetch` API polyfills if necessary, though `@buttercup/fetch` abstracts much of this.
Migrate to version 5.x as soon as possible to receive ongoing updates and security fixes. Review the breaking changes for v5 before migrating.
For optimal stability, performance, and support, use `webdav` v5 with Node.js 18 or newer. If using older Node.js versions, be prepared for potential compatibility issues and ensure thorough testing.
Configure your project's bundler to correctly handle ESM modules. The explicit `/web` entry point is still available but often not required with modern bundlers.
Change `require('webdav')` to `import { ... } from 'webdav';` and ensure your `package.json` has `'type': 'module'`, or downgrade to `webdav` version 4.x.Ensure you are using `import { createClient } from 'webdav';` for named exports, and avoid `import createClient from 'webdav';` unless the library explicitly exports a default. Check for correct module resolution in your build configuration.Verify Node.js version compatibility (>=14 for v5). If in a custom environment or older browser, ensure `global.fetch` is correctly polyfilled. `@buttercup/fetch` should handle `node-fetch` transparently in supported Node.js versions.
Check the WebDAV server's configuration and permissions for the affected path. Some servers are read-only or restrict certain operations. Ensure your client's authentication details are correct.