Search code examples
firebasevelo

The basic installation of firebase package in WIX project doesn't work


I installed firebase v-5.8.2 package through WIX's package manager. The installation process doesn't have any problem per se. After installation, I added "import * as firebase from 'firebase/app'", without any other code. When I run the project, it gave error message "can not find module 'fs'"

In the wix's forum, seems that someone had success experience with an earlier firebase version. Wondering if the v-5.8.2 has some problem with WIX.

import * as firebase from 'firebase/app'

"can not find module 'fs'"


Solution

  • You are importing it on a backend .jsw file, right?

    NPM modules can only be imported on backend files and not on your page code.

    You can export the functions from a backend file like below:

    //serverSide.jsw
    
    import firebase from 'firebase';
    
    var app = require('firebase');
    
    export function backendModule() {
            //Your backend function code here
    }
    

    Then import the function on the frontend page code like below:

    import {backendModule} from 'backend/serverSide.jsw';
    
    $w.onReady(function () {
        //TODO: write your page related code here...
    
    });
    

    If you are already importing on the backend file then try this below

    import firebase from 'firebase';