Search code examples
google-sheets-apinode-red

Has anyone used the "google-spreadsheet" npm in Node-RED?


I would like to be able to read cells from a Google Sheet inside my Node-RED project. I've tried including the node"google-spreadsheet" (https://www.npmjs.com/package/google-spreadsheet) in my package.json, and used it in a Node-RED function, but no luck. It is likely I am formatting the node.js invocations for this function incorrectly. I was hoping someone had a working example I could refer to (i.e. a Node-RED project pulling data from Google Sheets).


Solution

  • To use npm modules in the Function node you need to include them in your settings.js file so they can be added to the Function node context.

    Details of how to do this can be found in the doc here

    e.g. to add the os module to the function context you need to add the following to the functionGlobalContext section of the settings.js file:

    ...
    functionGlobalContext: {
        osModule:require('os')
    }
    ...