Homepage    |    GitHub    |    API    |    FAQ

Error in set up of "fs-extra" module

I am having a problem with the usage of 'fs-extra' module.Like I have tried these both methods-

Method-1

const fs = joplin.plugins.require('fs-extra');

This one is have error like no property require on "joplin.plugins".I think it is a version issue as minimum version supported by my plugin is 1.7. And this method is available for 1.8 and above.

Method-2

const fs = require('fs-extra');

and this one is throughing error something like this is coming on terminal -

  
    ERROR in ./dist/index.js
    Module not found: Error: Can't resolve 'fs' in '....\dist'
     @ ./dist/index.js 1:9350-9363

Like what is the proper way to install it I have installed this module with " npm install fs-extra " and it is present in my package.json.Now it is not present in the ./dist/index.js it means it is some kind of error related to the building process.

should be joplin.require

No, it is not working it is giving the same error as joplin.plugins.require , that is there is no property like require on Joplin.

 ERROR in ....\src\index.ts
    ./src/index.ts
    [tsl] ERROR in ....\src\index.ts(4,19)
          TS2339: Property 'require' does not exist on type 'Joplin'.

Actually, I have found both of the above-written code snippets from the "view demo plugin".

It was discussed here module not found: error: can't resolve 'fs' · Issue #4555 · laurent22/joplin · GitHub that a new version the plugin generator needs to be published. Not sure if @CalebJohn had a chance

1 Like

A temporary solution would be to do something like (joplin as any).require(....) to disable TypeScript type checking.

3 Likes

Yup, now it is working. :slight_smile: