Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Failed to load user script /scripts/AutomaticBookNotesFromReadwise.js. Default export is not a function. #54

Closed
leonardsellem opened this issue Jul 21, 2021 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@leonardsellem
Copy link

Describe the bug
When I launch the add book notes macro, an error message displays : "Failed to load user script /scripts/AutomaticBookNotesFromReadwise.js. Default export is not a function.".
Anyway, it creates a file for my book, but with a degraded template.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'command palette'
  2. Click on 'run QuickAdd'
  3. Click on 'Add book'
  4. Click on a book name
  5. See error

Expected behavior
A file should be created on the model of my template, with every variable filled properly.

Screenshots
Capture-d-e-cran-2021-07-21-a-11-06-17.png

Desktop (please complete the following information):

  • OS: MacOS 11.4
  • Browser Brave V1.26.77 (July 16, 2021)
  • Obsidian Version 0.12.10
@leonardsellem leonardsellem added the bug Something isn't working label Jul 21, 2021
@chhoumann
Copy link
Owner

Hey, @leonardsellem! Thank you for your report.

It looks like it's Templater that's complaining. Templater doesn't support that type of script, which is why I have the {{MACRO:Readwise::instaFetchBook}} in my book notes template.

Although, it does seem like the script ran (drawing this from the Author field being filled out), so I'm wondering if you both activate the script and try to call it from Templater?

@leonardsellem
Copy link
Author

Hi @chhoumann , thank you for your quick feedback !
Do you mean I need to deactivate Templater ?

@chhoumann
Copy link
Owner

That shouldn't be needed. But could you show me your entire template?

@leonardsellem
Copy link
Author

---
image: 
tags: in/books
aliases:
  - <% tp.file.title.replace('{ ', '') %>
cssclass: 
---

# Title: [[<%tp.file.title%>]]

## Metadata

Tags:: 
Type:: [[{]]
Author:: {{VALUE:author}}
Reference::
Rating:: 
Reviewed Date:: [[<%tp.date.now("gggg-MM-DD - ddd MMM D")%>]]
Finished Year:: [[<%tp.date.now("gggg")%>]]

# Thoughts

# Actions Taken / Changes

# Summary of Key Points

# Highlights & Notes
{{MACRO:Readwise::instaFetchBook}}

@leonardsellem
Copy link
Author

Highlights are being imported through

@chhoumann
Copy link
Owner

Thank you! Do you by chance have your Templater scripts folder set to the same folder as the one you placed this script in?

I'm referring to this setting in Templater
image

Because if you did, Templater will try to 'understand' it - which it can't, because it's not supported by Templater.

As you can see in my image, I actually ended up giving Templater its own folder within my 'scripts' folder.

So maybe just create a separate folder for QuickAdd scripts. Or do what I did and create a 'Templater' folder within your scripts folder and tell Templater to look there - and move your Templater scripts there, of course.

@leonardsellem
Copy link
Author

You rock ! It works so well !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants