Skip to content

process is not defined error with angular 12 [Bug] #284

Open
@nileshzala005

Description

@nileshzala005

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "util": require.resolve("util/") }'
- install 'util'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "util": false }

With Angular 12, this is working fine in Angular 11

Angular CLI: 12.0.0
Node: 14.15.4
Package Manager: npm 6.14.10
OS: darwin x64

Angular:
...

Package Version

@angular-devkit/architect 0.1200.0 (cli-only)
@angular-devkit/core 12.0.0 (cli-only)
@angular-devkit/schematics 12.0.0 (cli-only)
@schematics/angular 12.0.0 (cli-only)

If install util js via npm install util
build error is removed but at runtime getting this error.
util.js:109 Uncaught ReferenceError: process is not defined
at Object.1732 (util.js:109)

internally util js is used by twilio-client sdk
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');
}

here at the client-side its try to get process object that is node server object. this is causing the issue in angular 12

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions