diff --git a/packages/htmlpack/src/index.ts b/packages/htmlpack/src/index.ts
index 6dae9d4fe..5659ac8be 100644
--- a/packages/htmlpack/src/index.ts
+++ b/packages/htmlpack/src/index.ts
@@ -1,4 +1,5 @@
import * as fs from 'fs-extra';
+import { pathExistsSync } from 'fs-extra';
const Entities = require('html-entities').AllHtmlEntities;
const htmlparser2 = require('@joplin/fork-htmlparser2');
const Datauri = require('datauri/sync');
@@ -102,6 +103,7 @@ const processLinkTag = (baseDir: string, _name: string, attrs: any): string => {
const filePath = `${baseDir}/${href}`;
+ if (!pathExistsSync(filePath)) return null;
const content = fs.readFileSync(filePath, 'utf8');
return ``;
};
diff --git a/packages/lib/services/interop/InteropService_Exporter_Html.ts b/packages/lib/services/interop/InteropService_Exporter_Html.ts
index e8aa08e62..8142cd275 100644
--- a/packages/lib/services/interop/InteropService_Exporter_Html.ts
+++ b/packages/lib/services/interop/InteropService_Exporter_Html.ts
@@ -15,6 +15,9 @@ const { escapeHtml } = require('../../string-utils.js');
import { assetsToHeaders } from '@joplin/renderer';
import getPluginSettingValue from '../plugins/utils/getPluginSettingValue';
import { LinkRenderingType } from '@joplin/renderer/MdToHtml';
+import Logger from '@joplin/utils/Logger';
+
+const logger = Logger.create('InteropService_Exporter_Html');
export default class InteropService_Exporter_Html extends InteropService_Exporter_Base {
@@ -136,11 +139,15 @@ export default class InteropService_Exporter_Html extends InteropService_Exporte
for (let i = 0; i < result.pluginAssets.length; i++) {
const asset = result.pluginAssets[i];
const filePath = asset.pathIsAbsolute ? asset.path : `${libRootPath}/node_modules/@joplin/renderer/assets/${asset.name}`;
- const destPath = `${dirname(noteFilePath)}/pluginAssets/${asset.name}`;
- const dir = dirname(destPath);
- await shim.fsDriver().mkdir(dir);
- this.createdDirs_.push(dir);
- await shim.fsDriver().copy(filePath, destPath);
+ if (!(await shim.fsDriver().exists(filePath))) {
+ logger.warn(`File does not exist and cannot be exported: ${filePath}`);
+ } else {
+ const destPath = `${dirname(noteFilePath)}/pluginAssets/${asset.name}`;
+ const dir = dirname(destPath);
+ await shim.fsDriver().mkdir(dir);
+ this.createdDirs_.push(dir);
+ await shim.fsDriver().copy(filePath, destPath);
+ }
}
const fullHtml = `