adamhalasz / uniqid

Unique ID Generator
https://adamhalasz.com
617 stars 49 forks source link

'process && process.pid' test doesn't work in strict mode #20

Open hacker64 opened 6 years ago

hacker64 commented 6 years ago

I'd suggest changing the following: var pid = process && process.pid ? process.pid.toString(36) : '' ; to: var pid = typeof process !== 'undefined' && process.pid ? process.pid.toString(36) : '' ;

The 2nd version is more portable and safer. I pulled the uniqid module into an Angular 6 project and the code ended up running in strict mode, which caused a ReferenceError on 'process'.

dri-developer commented 6 years ago

I too experienced this error with Angular 6

lubkoKuzenko commented 5 years ago

add this to polyfills.js

(window as any).process = {
  env: { DEBUG: undefined }
};