The import of third party module is failing in main.js : Cannot find module

main.ts is not showing any error.
But in main.js, the line var jsforce = require(‘jsforce’); is giving below error.

Plugin failure: obsidian-sample-plugin Error: Cannot find module ‘jsforce’
Require stack:

  • electron/js2c/renderer_init
    at Module._resolveFilename (internal/modules/cjs/loader.js:972)
    at Function.i._resolveFilename (electron/js2c/renderer_init.js:35)
    at Module._load (internal/modules/cjs/loader.js:848)
    at Function.f._load (electron/js2c/asar_bundle.js:5)
    at Module.require (internal/modules/cjs/loader.js:1032)
    at require (internal/modules/cjs/helpers.js:72)
    at Le (app.js:1)
    at a (app.js:1)
    at anonymous (eval at (app.js:1), :10:15)
    at t. (app.js:1)

I found a workaround to resolve this, manually editing and providing the full path of the jsforce.js file

var jsforce = require(app.vault.adapter.basePath + ‘/.obsidian/plugins/obsidian-sample/node_modules/jsforce/lib/jsforce.js’);

And it’s working fine.

Can someone please help me why the module ‘jsforce’ is unable to resolve correctly with out giving the full path? Is there any step am I missing?

Please note: main.ts file is not showing any error.

Also, I am curious, how require(‘obsidian’) is getting picked up correctly.