Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

fix: electron cannot be started in Windows (#2784)

JimmFly7eaff644e393
diff --git a/apps/electron/package.json b/apps/electron/package.json
index d07cc3044a..778e91d50f 100644
--- a/apps/electron/package.json
+++ b/apps/electron/package.json
@@ -57,6 +57,7 @@
"ts-node": "^10.9.1",
"undici": "^5.22.1",
"uuid": "^9.0.0",
+ "which": "^3.0.1",
"zx": "^7.2.2"
},
"dependencies": {
diff --git a/apps/electron/scripts/dev.mjs b/apps/electron/scripts/dev.mjs
index 9960439eac..5bb50ffdcc 100644
--- a/apps/electron/scripts/dev.mjs
+++ b/apps/electron/scripts/dev.mjs
@@ -5,6 +5,7 @@ import path, { resolve } from 'node:path';
import electronPath from 'electron';
import * as esbuild from 'esbuild';
+import which from 'which';
import { config, electronDir, rootDir } from './common.mjs';
@@ -67,9 +68,9 @@ function spawnOrReloadElectron() {
}
const common = config();
-
+const yarnPath = which.sync('yarn');
async function watchPlugins() {
- spawn('yarn', ['dev'], {
+ spawn(yarnPath, ['dev'], {
stdio: 'inherit',
cwd: resolve(rootDir, './packages/plugin-infra'),
});
diff --git a/apps/electron/src/main/plugin.ts b/apps/electron/src/main/plugin.ts
index 445d8fd390..337cda0619 100644
--- a/apps/electron/src/main/plugin.ts
+++ b/apps/electron/src/main/plugin.ts
@@ -38,7 +38,7 @@ export function registerPlugin() {
'./bookmark-block/index.mjs'
);
logger.info('bookmark plugin path:', bookmarkPluginPath);
- import(bookmarkPluginPath);
+ import('file://' + bookmarkPluginPath);
let dispose: () => void = () => {
// noop
};
diff --git a/apps/electron/src/main/workers/plugin.worker.ts b/apps/electron/src/main/workers/plugin.worker.ts
index f4bcaf12d9..a0af86929d 100644
--- a/apps/electron/src/main/workers/plugin.worker.ts
+++ b/apps/electron/src/main/workers/plugin.worker.ts
@@ -34,7 +34,7 @@ import('@toeverything/plugin-infra/manager')
console.log('import bookmark plugin', bookmarkPluginPath);
- import(bookmarkPluginPath).catch(console.log);
+ import('file://' + bookmarkPluginPath).catch(console.log);
rootStore.sub(affinePluginsAtom, () => {
const plugins = rootStore.get(affinePluginsAtom);
Object.values(plugins).forEach(plugin => {
diff --git a/yarn.lock b/yarn.lock
index 0e55275da1..8cf96a6bb1 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -193,6 +193,7 @@ __metadata:
ts-node: ^10.9.1
undici: ^5.22.1
uuid: ^9.0.0
+ which: ^3.0.1
yjs: ^13.6.1
zx: ^7.2.2
peerDependencies:
@@ -28301,7 +28302,7 @@ __metadata:
languageName: node
linkType: hard
-"which@npm:^3.0.0":
+"which@npm:^3.0.0, which@npm:^3.0.1":
version: 3.0.1
resolution: "which@npm:3.0.1"
dependencies: