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

**URL:** <https://forum.obsidian.md/t/the-import-of-third-party-module-is-failing-in-main-js-cannot-find-module/25180>\
**Category:** Devs: Plugins & API\
**Created:** [October 4, 2021, 7:00pm UTC](https://forum.obsidian.md/t/the-import-of-third-party-module-is-failing-in-main-js-cannot-find-module/25180 "2021-10-04T19:00:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![AAK](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/a/439d5e/32.png) [@AAK](https://forum.obsidian.md/u/AAK)\
**Post date:** [October 4, 2021, 7:00pm UTC](https://forum.obsidian.md/t/the-import-of-third-party-module-is-failing-in-main-js-cannot-find-module/25180/1 "2021-10-04T19:00:02Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![magdaddy](https://forum.obsidian.md/letter_avatar_proxy/v4/letter/m/e68b1a/32.png) [@magdaddy](https://forum.obsidian.md/u/magdaddy)\
**Post date:** [October 29, 2021, 1:19pm UTC](https://forum.obsidian.md/t/the-import-of-third-party-module-is-failing-in-main-js-cannot-find-module/25180/2 "2021-10-29T13:19:05Z")

</div>

I had a similar problem and asked in the Discord, this is what Licat replied:

> You need to bundle your plugin - we only load main.js using eval as a string so it doesn’t actually load from your file path.  
> If using js either write it all in one file or use a bundle like webpack or esbuild

Hope that helps you too…
