Giter Site home page Giter Site logo

Comments (5)

enuchi avatar enuchi commented on July 29, 2024

You can't install node packages on the server unfortunately. Google Apps Script doesn't actually run node, it's just a javascript engine.

If you want to make http requests from the server you'll need to use Google Apps Script's UrlFetchApp service:
https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app#fetch(String,Object)

from react-google-apps-script.

kickbox avatar kickbox commented on July 29, 2024

Hi @enuchi, thanks for getting back. Since App Script uses V8 runtime, can I install any package and run within the server environment? My use case goes beyond the axios example, sorry for not making it clear. Another example would be slack api - https://www.npmjs.com/package/slack.

from react-google-apps-script.

enuchi avatar enuchi commented on July 29, 2024

No @kickbox, I don't think the slack api won't work, since it is intended to run in node and expects the node libraries to be available. If you want to make HTTP requests, for instance for a slack integration, you'll have to use the UrlFetchApp service.

V8 runtime does not mean it is running node on the server. It is just a javascript engine that can process javascript code. The Google Apps Script environment does not include all the features that node does.

By the way, certain npm packages that don't have any external dependencies might work, for instance lodash or moment.js or other packages like that that are written in pure javascript. Try it out and let me know if you have any luck!

from react-google-apps-script.

kickbox avatar kickbox commented on July 29, 2024

Thanks @enuchi, that makes sense. How should I go about installing a package like moment.js for serverside? Would creating a local clone be the best option?

from react-google-apps-script.

kickbox avatar kickbox commented on July 29, 2024

Installing moment.js is easy, just had to put the entire source code in a directory and reference it. Generally I think anything that requires npm and has dependencies in package.json wont work.

from react-google-apps-script.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.