ReferenceError: self is not defined

Posted by: marcio.shimoda on 18 March 2023, 11:44 am EST

  • Posted 18 March 2023, 11:44 am EST - Updated 11 January 2024, 5:40 am EST

    I’m writing some code to load a SpreadJS JSON with Node JS using the “How to Generate an Excel Spreadsheet From your Node.js Application” example

    But after upgrading SpreadJS to 15.2.5 version I got

    ReferenceError: self is not defined

    at Module…/node_modules/whatwg-fetch/fetch.js …

  • Posted 19 March 2023, 5:17 pm EST

    Hello Marcio,

    With the SpreadJS V15/V16, you need to add one crucial line that enables compatibility with SpreadJS V15/V16:

    global.self = global;

    You may refer to the attached sample that is based on the steps outlined in the blog post located at

    Please refer to the modified sample file attached herewith. To run the application successfully, start by installing the dependencies using the ‘npm install’ command. Afterward, on line number 14 and 15, add a valid license key. Finally, run the application with the ‘node index.js’ command. Upon successful execution, you should be able to see the name of the sheet and the value of Cell A1 being logged in the console.

    Please note that the attached sample uses the SpreadJS V16(the latest version). You may change the SpreadJS Version in package.json file and set the License Key for V15 in the index.js file.

    If you encounter any issues, please do not hesitate to reach out to us. We look forward to hearing about your experience with the updated sample.

    Best regards,



Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels