Skip to content

Node 14: ReferenceError: regeneratorRuntime is not defined #312

Open

Description

@1valdis

I'm trying to use this package on Node server. After doing npm i @teamleader/api and creating a file with the simplest piece of code:

import API from '@teamleader/api';

When trying to run it I'm getting the following error:

<project_folder>\node_modules\@teamleader\api\dist\cjs\utils\getResponseData.js:17
  regeneratorRuntime.mark(function _callee(response) {
  ^

ReferenceError: regeneratorRuntime is not defined
    at <project_folder>\node_modules\@teamleader\api\dist\cjs\utils\getResponseData.js:17:3
    at Object.<anonymous> (<project_folder>\node_modules\@teamleader\api\dist\cjs\utils\getResponseData.js:46:2)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (<project_folder>\node_modules\@teamleader\api\dist\cjs\utils\checkStatus.js:8:47)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)

Any info on how to solve this?

Activity

  1. ArnaudWeyts commented on Jan 11, 2021

    @ArnaudWeyts
    Contributor

    Hey @1valdis, thanks for reporting this issue!

    After some initial research, I realised we don't build this package for Node environments, hence why the transpiled code (for async-await) doesn't work. I thought I could solve it by just correctly transpiling the module to support Node but then I realised we use the browser-specific fetch API to do the requests. So I'm afraid some more work will be needed in order to support Node environments. This isn't currently a priority for us as we only use the package in browser environments, but pull requests are highly encouraged and appreciated!

  2. 1valdis commented on Jan 11, 2021

    @1valdis
    Author

    @ArnaudWeyts considering browser's Fetch API, you may take a look at a popular node-fetch package. I didn't use it myself but it is widely popular and positions itself as a Fetch API implementation for Node environment.

  3. mniesen commented on Jul 7, 2021

    @mniesen

    I'm trying to use this package on Node server. After doing npm i @teamleader/api and creating a file with the simplest piece of code:

    import API from '@teamleader/api';

    When trying to run it I'm getting the following error:

    <project_folder>\node_modules\@teamleader\api\dist\cjs\utils\getResponseData.js:17
      regeneratorRuntime.mark(function _callee(response) {
      ^
    
    ReferenceError: regeneratorRuntime is not defined
        at <project_folder>\node_modules\@teamleader\api\dist\cjs\utils\getResponseData.js:17:3
        at Object.<anonymous> (<project_folder>\node_modules\@teamleader\api\dist\cjs\utils\getResponseData.js:46:2)
        at Module._compile (internal/modules/cjs/loader.js:1063:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
        at Module.load (internal/modules/cjs/loader.js:928:32)
        at Function.Module._load (internal/modules/cjs/loader.js:769:14)
        at Module.require (internal/modules/cjs/loader.js:952:19)
        at require (internal/modules/cjs/helpers.js:88:18)
        at Object.<anonymous> (<project_folder>\node_modules\@teamleader\api\dist\cjs\utils\checkStatus.js:8:47)
        at Module._compile (internal/modules/cjs/loader.js:1063:30)
    

    Any info on how to solve this?

    Same problem. But I don't understand why this package is on npmjs.com if it's only for javascript.

  4. ArnaudWeyts commented on Jul 7, 2021

    @ArnaudWeyts
    Contributor

    I'm trying to use this package on Node server. After doing npm i @teamleader/api and creating a file with the simplest piece of code:

    import API from '@teamleader/api';

    When trying to run it I'm getting the following error:

    <project_folder>\node_modules\@teamleader\api\dist\cjs\utils\getResponseData.js:17
      regeneratorRuntime.mark(function _callee(response) {
      ^
    
    ReferenceError: regeneratorRuntime is not defined
        at <project_folder>\node_modules\@teamleader\api\dist\cjs\utils\getResponseData.js:17:3
        at Object.<anonymous> (<project_folder>\node_modules\@teamleader\api\dist\cjs\utils\getResponseData.js:46:2)
        at Module._compile (internal/modules/cjs/loader.js:1063:30)
        at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
        at Module.load (internal/modules/cjs/loader.js:928:32)
        at Function.Module._load (internal/modules/cjs/loader.js:769:14)
        at Module.require (internal/modules/cjs/loader.js:952:19)
        at require (internal/modules/cjs/helpers.js:88:18)
        at Object.<anonymous> (<project_folder>\node_modules\@teamleader\api\dist\cjs\utils\checkStatus.js:8:47)
        at Module._compile (internal/modules/cjs/loader.js:1063:30)
    

    Any info on how to solve this?

    Same problem. But I don't understand why this package is on npmjs.com if it's only for javascript.

    @mniesen Hey, thanks for commenting on this issue. This package was never created to run on a server. To answer your question: there are tons of packages on npm that only work in certain environments (think UI-libraries etc.), Supporting multiple environments is not a requirement for publishing.

  5. laurenskling commented on Jun 21, 2022

    @laurenskling

    @ArnaudWeyts you can simply install cross-fetch to have fetch working on both ends

  6. ArnaudWeyts commented on Jun 21, 2022

    @ArnaudWeyts
    Contributor

    @ArnaudWeyts you can simply install cross-fetch to have fetch working on both ends

    @laurenskling Thanks for the proposal! As I mentioned in the other comment, it's not currently a priority for us to support node in this package. Especially seeing as fetch is getting implemented in node following the official specification: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API#browser_compatibility

    Fetch should be available starting from Node v18

  7. laurenskling commented on Jun 21, 2022

    @laurenskling

    Thanks for the quick response @ArnaudWeyts .
    Any suggestions on working with the Teamleader API from NodeJS backend?
    https://developer.teamleader.eu/#/introduction/authentication is pretty focussed on frontend access

  8. ArnaudWeyts commented on Jun 21, 2022

    @ArnaudWeyts
    Contributor

    @laurenskling Nothing more than what is defined in our api documentation, we ourselves only use this package on the frontend side of things (for now).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions