I'm trying to import a 3rd party javascript library from static resources in my lightning web component. I followed the exemple given in LWC documentation.

I encounter the folowing error :

Uncaught (in promise) TypeError: Cannot read property 'Symbol(ViewModel)' of undefined

Uncaught (in promise) TypeError: m is not a function

My sample code :

import loadScript from 'lightning/platformResourceLoader';
import fuse from '@salesforce/resourceUrl/fuse';

export default class SelectActivity extends LightningElement {

    fuseLoaded = false;

    renderedCallback() {
            loadScript(this,fuse + "/fuse.js")
                .then( () => {
                    this.fuseLoaded = true;
                .catch( error => console.log(error));



And my static resource is present :

Static resource

Thank you in advance


You are passing a path variable in your loadScript call (/fuse.js) which is required when you want to load a file inside an archive When you upload the javascript file directly (which is the case based on your screenshot) you only pass the import identifier as 2nd argument

  • and then there is also the fact that the library might not be locker service compliant, which might lead to other/similar issues after =/ – glls Jul 16 '19 at 11:34
  • Hello, thank you for both of your answers. I tried using @Renji-XD's line but it gives me the same error. Furthermore, I don't think that the issue is with Locker Service compliance because a colleage of mine uses this lib in Aura Components without problem. – Ombrelin Jul 17 '19 at 9:21
  • that means nothing - i also already encountered stuff which works fine in aura but not in lwc. I tried your lib (assuming it is fusejs.io) and got no error.so i can`t really give any further hints as from my side everything looks ok – Renji-xD Jul 17 '19 at 13:12
  • I finally got it to work the problem was that the imported fuse varaible wasn't seen, I had to create a field in my controller class and assin the imported value to it. – Ombrelin Jul 22 '19 at 14:32

As said above, loadScript(this,fuse) should work fine.

Adding to it, you should not load script in renderedCallback as it will be invoked for every api/track variable change (unless it needs to like in case of graph where graph changes with every parameter change). You should be using connectedCallback instead.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.