twilio / twilio-taskrouter.js

JS SDK v2 for Twilio's TaskRouter skills based routing system.
https://www.twilio.com/docs/taskrouter
Other
23 stars 32 forks source link

Angular v17: Uncaught ReferenceError: process is not defined #121

Open pras-bot opened 3 months ago

pras-bot commented 3 months ago

I am using 'twilio-taskrouter' v2.0.3 npm package in Angular v17 app. Getting error on accessing the app from browser:

    at node_modules/util/util.js (util.js:109:1)
    at __require (chunk-ZTDPENTR.js?v=8eb4eef9:38:50)
    at 6464 (index.window.js:3:115268)
    at r2 (index.window.js:3:119424)
    at 5600 (index.window.js:3:108312)
    at r2 (index.window.js:3:119424)
    at 568 (index.window.js:3:95429)
    at r2 (index.window.js:3:119424)
    at 6427 (index.window.js:3:97502)
    at r2 (index.window.js:3:119424)

I have debugged this further, twilio-taskrouter is importing 'util' package, which tries to access the (Node) 'process' variable:

if (process.env.NODE_DEBUG) {
  var debugEnv = process.env.NODE_DEBUG;
  debugEnv = debugEnv.replace(/[|\\{}()[\]^$+?.]/g, '\\$&')
    .replace(/\*/g, '.*')
    .replace(/,/g, '$|^')
    .toUpperCase();
  debugEnvRegex = new RegExp('^' + debugEnv + '$', 'i');
}
andreasonny83 commented 3 months ago

Hello @pras-bot. Thanks for highlighting this. From what I can see, there's no mention of process.env inside the distribution folder of the twilio-taskrouter@2.0.3 package. I'm assuming your errors might come from a TypeScript compiler when processing the third party modules in use by the twilio-taskrouter package. I would suggest you to enable the skipLibCheck flag under your tsconfig.json and see if that helps in mitigating the problem. Also, since you mention the problem is showing when consuming twilio-taskrouter v2.0.3, can you please specify if the same problem is also visible when reverting the package to an older version?

Please, let me know if that worked.

GhazanfarKhan commented 1 week ago

@andreasonny83 I am also getting same error with 2.0.6 version. My angular version is 17 and skipLibCheck is enabled in tsconfig.json. Need help

GhazanfarKhan commented 2 days ago

Any update we have to update package in our project stuck in this issue.