twilio-taskrouter.js icon indicating copy to clipboard operation
twilio-taskrouter.js copied to clipboard

Angular v17: Uncaught ReferenceError: process is not defined

Open pras-bot opened this issue 1 year ago • 3 comments

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');
}

pras-bot avatar Mar 20 '24 14:03 pras-bot

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 [email protected] 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.

andreasonny83 avatar Mar 27 '24 14:03 andreasonny83

@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 avatar Jun 25 '24 15:06 GhazanfarKhan

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

GhazanfarKhan avatar Jul 03 '24 12:07 GhazanfarKhan