Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node 14: ReferenceError: regeneratorRuntime is not defined #312

Open
1valdis opened this issue Jan 11, 2021 · 8 comments
Open

Node 14: ReferenceError: regeneratorRuntime is not defined #312

1valdis opened this issue Jan 11, 2021 · 8 comments

Comments

@1valdis
Copy link

1valdis commented Jan 11, 2021

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?

@ArnaudWeyts
Copy link
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!

@1valdis
Copy link
Author

1valdis commented Jan 11, 2021

@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.

@mniesen
Copy link

mniesen commented Jul 7, 2021

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.

@ArnaudWeyts
Copy link
Contributor

ArnaudWeyts commented Jul 7, 2021

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.

@laurenskling
Copy link

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

@ArnaudWeyts
Copy link
Contributor

ArnaudWeyts commented Jun 21, 2022

@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

@laurenskling
Copy link

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

@ArnaudWeyts
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants