Fix matrix-js-sdk linking on Windows (#33491)

* Fix matrix-js-sdk linking on Windows

* Linting
This commit is contained in:
Travis Ralston
2026-05-14 09:23:33 -06:00
committed by GitHub
parent ab904bb6ca
commit a12296630a
2 changed files with 24 additions and 10 deletions
+4
View File
@@ -45,6 +45,8 @@ Set up your local development link by creating a `.link-config` file with conten
matrix-js-sdk=/path/to/matrix-js-sdk
```
**Note for Windows users**: Your link config path might need escaping. For example, `matrix-js-sdk=C:\\path\\to\\matrix-js-sdk`.
Switch to the `apps/web` directory: `cd apps/web`
Configure the app by copying `config.sample.json` to `config.json` and
@@ -57,6 +59,8 @@ pnpm install
pnpm start
```
**Note for Windows users**: `pnpm start` needs to be run from a terminal with bash/shell support.
Wait a few seconds for the initial build to finish; you should see something like:
```
+20 -10
View File
@@ -32,21 +32,31 @@ try {
const dependencyPath = join(nodeModulesPath, dependency);
try {
const stat = await fs.stat(dependencyPath);
if (stat.isSymbolicLink()) {
const linkPath = await fs.readlink(dependencyPath);
if (linkPath === path) {
// already done
continue;
try {
const stat = await fs.lstat(dependencyPath);
console.log(`Existing is ${stat.isSymbolicLink() ? "symlink" : "directory"}`);
if (stat.isSymbolicLink()) {
const linkPath = await fs.readlink(dependencyPath);
if (linkPath === path) {
// already done
continue;
} else {
await fs.unlink(dependencyPath);
}
} else {
await fs.unlink(dependencyPath);
await fs.rm(dependencyPath, { recursive: true });
}
} catch (e: any) {
// fs.lstat throws ENOENT if the path doesn't exist (on Windows)
if (e.code === "ENOENT") {
console.log("Received ENOENT error on dependency path - assuming it doesn't exist");
} else {
throw e;
}
} else {
await fs.rm(dependencyPath, { recursive: true });
}
console.log(`Linking ${dependency} to ${path}`);
await fs.symlink(path, dependencyPath);
await fs.symlink(path, dependencyPath, "junction"); // use a junction type to avoid EPERM errors on Windows
const pkgJson = await fs.readFile(join(path, "package.json"), "utf-8");
const pkgManager = JSON.parse(pkgJson)["packageManager"]?.split("@").at(0) ?? "yarn";