Skip to content

Windows setup: connector, base64, and search (fs.walk) problems & solutions #3

@Pilsertech

Description

@Pilsertech

Common Problems & Solutions When Setting Up elfinder-node (Windows/Node.js)

1. Setting up connectors and file paths

  • Problem: Issues with target hashes, root paths, and connector URLs (especially on Windows).
  • Solution: Double-check your connector configuration (roots, path, URL) in the backend. Ensure paths use correct slashes (\ for Windows, / for Linux). For initial blank targets, patch to use the correct hash (e.g., v0_Lw for / root).

2. "The string to be encoded contains characters outside of the Latin1 range."

  • Problem: Base64 encoding/decoding fails with non-Latin1 strings (Unicode paths, etc.).
  • Solution: Replace uses of the base-64 npm package with Node.js Buffer for base64 encoding/decoding in lfs.utils.js:
    const base64 = {
      encode: (str) => Buffer.from(str, 'utf8').toString('base64'),
      decode: (str) => Buffer.from(str, 'base64').toString('utf8')
    };
    This works for all Unicode file paths.

3. Search fails: "TypeError: fs.walk is not a function"

  • Problem: elfinder-node's search uses the deprecated fs.walk API, which is not present in recent fs-extra.
  • Solution: Replace the api.search implementation in LocalFileStorage.js with a custom async recursive function using fs.readdir and fs.stat:
    api.search = async function (opts, res) {
      // ... see detailed code in thread ...
    };
    This removes the dependency on fs.walk and works for all directory trees.

General Tip

  • Always check your Node.js version and your dependencies (fs-extra, etc.).
  • If you update elfinder-node, re-apply these fixes as needed.

Thanks to the community for their help! If you need more details, see the full discussion or ask below.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions