You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Node 14: ReferenceError: regeneratorRuntime is not defined #312
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:
importAPIfrom'@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)
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!
@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.
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:
importAPIfrom'@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.
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:
importAPIfrom'@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.
Activity
ArnaudWeyts commentedon Jan 11, 2021
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 commentedon 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 commentedon Jul 7, 2021
Same problem. But I don't understand why this package is on npmjs.com if it's only for javascript.
ArnaudWeyts commentedon Jul 7, 2021
@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 commentedon Jun 21, 2022
@ArnaudWeyts you can simply install
cross-fetchto havefetchworking on both endsArnaudWeyts commentedon Jun 21, 2022
@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 commentedon Jun 21, 2022
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 commentedon Jun 21, 2022
@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).