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

[BUG] - process is undefined on Angular #267

Closed
pl4yradam opened this issue Oct 25, 2022 · 5 comments
Closed

[BUG] - process is undefined on Angular #267

pl4yradam opened this issue Oct 25, 2022 · 5 comments

Comments

@pl4yradam
Copy link

When running Angular projects now using the package, the latest 3.3 fix from this commit breaks it

2992146

Angular runs in the browser and doesn't have a concept of process. Can this be reverted?

Temporary solutions:

  • Reverting to previous version
  • Defining Globals for process, however that is not correct for client side development practices.

Error dump:
Uncaught ReferenceError: process is not defined at 5006 (JSEncrypt.js:3:15) at __webpack_require__ (bootstrap:19:1) at 1287 (JSEncryptRSAKey.js:320:28) at __webpack_require__ (bootstrap:19:1) at 1677 (router.mjs:6124:1) at __webpack_require__ (bootstrap:19:1) at 6747 (app.component.html:5:7) at __webpack_require__ (bootstrap:19:1) at 4431 (environment.ts:14:3) at __webpack_require__ (bootstrap:19:1)

@heyixing
Copy link

also in vue, someone add process vars in the latest version 3.30

@lribeirodev
Copy link

lribeirodev commented Oct 26, 2022

We noticed this error on the project too, after doing some search about it, I found a workaround
and added the following code inside to <angular_project>/src/polyfills.ts

(window as any).process = {env: {}}; // added global env variable

resolved the problem!

@pl4yradam
Copy link
Author

pl4yradam commented Oct 27, 2022

We noticed this error on the project too, after doing some search about it, I found a workaround and added the following code inside to <angular_project>/src/polyfills.ts

(window as any).process = {env: {}}; // added global env variable

resolved the problem!

This shouldnt be needed for client side development, overwriting global behavior is a plaster not a fix

@lribeirodev
Copy link

lribeirodev commented Oct 27, 2022

We noticed this error on the project too, after doing some search about it, I found a workaround and added the following code inside to <angular_project>/src/polyfills.ts

(window as any).process = {env: {}}; // added global env variable

resolved the problem!

This shouldnt be needed for client side development, overwriting global behavior is a plaster not a fix

I Agree with you, my friend found a better solution, setting the version of the lib in package.json without the bug is better, have a great day!

@pl4yradam
Copy link
Author

We noticed this error on the project too, after doing some search about it, I found a workaround and added the following code inside to <angular_project>/src/polyfills.ts
(window as any).process = {env: {}}; // added global env variable
resolved the problem!

This shouldnt be needed for client side development, overwriting global behavior is a plaster not a fix

I Agree with you, my friend found a better solution, setting the version of the lib in angular.json without the bug is better, have a great day!

That will indeed work on a per project basis e.g. setting package.json to "jsencrypt": "3.2.1" this will allow it to work, however with peer dependencies working on multiple projects at one with internal packages, this will break.

Glad that solution has worked for you 👍 Reverting the version is a good short term fix

TimUnderhay pushed a commit to TimUnderhay/jsencrypt that referenced this issue Oct 30, 2022
travist added a commit that referenced this issue Nov 2, 2022
Fix for running in browser (addresses #267).
@travist travist closed this as completed Nov 11, 2022
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