TypeError: Script methods can only be called on script instances

Since the most recent update all my dataviewjs references are getting the following error:

TypeError: Script methods can only be called on script instances.

Steps to reproduce

For example:


Which contains the following script:

var dvUtils = require(app.vault.adapter.basePath + "/πŸ“¦ Resources/πŸƒβ€β™‚οΈ Runbooks/🧰 Devops/dv-views/dvUtils.js");

let curr = dv.current();
let quote = curr.file.frontmatter.quote;
let sources = curr.file.frontmatter.sources;
let person = sources[0].person != "" ? sources[0].person : "Unknown";
let place = sources[0].place != "" ? sources[0].place : "Unknown";
let location = sources[0].location != "" ? " | " + sources[0].location : "";
let acknowledgement;

let quoteblock = `

>[!quote] ${quote}

><span class="source"><span class="person"> ${person} </span></br>

><span class="place">${place} ${location}</span></span>



Did you follow the troubleshooting guide? [Y/N]

I did but I had some trouble recreating the issue exactly. From this I did confirm that the issue is based on the first line:

var dvUtils = require(app.vault.adapter.basePath + "/πŸ“¦ Resources/πŸƒβ€β™‚οΈ Runbooks/🧰 Devops/dv-views/dvUtils.js");

I’m assuming this error refers to the require() but I don’t understand the language β€œScript methods can only be called on script instances.”

Expected result

Actual result


Obsidian version: v1.4.2
Installer version: v1.3.4
Operating system: Darwin Kernel Version 22.5.0: Thu Jun 8 22:22:20 PDT 2023; root:xnu-8796.121.3~7/RELEASE_ARM64_T6000 22.5.0
Login status: logged in
Catalyst license: insider
Insider build toggle: on
Live preview: on
Legacy editor: off
Base theme: dark
Community theme: Things v2.1.6
Snippets enabled: 4
Restricted mode: off
Plugins installed: 33
Plugins enabled: 20
1: Hotkeys++ v0.2.7
2: Natural Language Dates v0.6.1
3: Templater v1.16.0
4: Periodic Notes v0.0.17
5: Obsidian Query Language v2.1.1
6: Dataview v0.5.56
7: Advanced Mobile Toolbar v1.8.0
8: Advanced Tables v0.19.1
9: Folder Note v0.7.3
10: PlantUML v1.6.6
11: QuickAdd v1.2.1
12: Tag Wrangler v0.5.11
13: Banners v1.3.3
14: LanguageTool Integration v0.3.4
15: Calendar v1.5.10
16: Bible Reference v1.7.3
17: Scales and Chords v1.0.1
18: Excalidraw v1.9.15
19: Importer v1.1.0
20: Tasks v4.5.0

Additional information

I use this require() call on all my scripts to have common functions available to me so any help in understanding the issue will help. Thanks!

Moved to help

1 Like

After some searching I think it might be related to this Electron bug: [Bug]: proxyquire can't load modules after window.open method is called Β· Issue #37404 Β· electron/electron Β· GitHub

I’ve decided to inline my shared JS code so I can do without require.

Unfortunately that works. It resolves the error message but really limits my scripting to have to repeat utility code throughout the various scripts. From what you shared this sounds like an issue that Electon has to resolve and not the Obsidian team, correct?

As far as I can tell: yes.