await-semaphore icon indicating copy to clipboard operation
await-semaphore copied to clipboard

Cannot find name 'process'

Open AndersonBP opened this issue 7 years ago • 5 comments

I am trying to use in an angled project 4 with typescript, however I get this error:

node_modules/await-semaphore/index.ts (34,17): Cannot find name 'process'

AndersonBP avatar Feb 21 '18 21:02 AndersonBP

same problem here.. Uncaught (in promise): ReferenceError: process is not defined

ErikParso avatar Oct 11 '19 12:10 ErikParso

process does not exist within a non node.js enbvironment. If you use it in a web app, it fails. I encountered the same problem but haven't found a solution yet.

smuddy avatar Sep 15 '20 13:09 smuddy

If you're still having problems with this, I worked around it by using the following in conjunction with webpack:

webpack.config.js:

import webpack from "webpack";
const { DefinePlugin } = webpack;

export default async (env, options) => {
  return {
    //other options removed for brevity
    plugins: [
      new DefinePlugin({
        // we need this because the "await-semaphore" library typically runs in node, and looks for 'process'. Since we are a browser library, set this to false to short-circuit the statement
        process: false,
      }),
    ],
  };
};

celluj34 avatar Feb 02 '22 17:02 celluj34

Simple redefine of process doesn't help and leads to other "undefined" errors. Better approach is to use process shim. I use node package "process": "^0.11.10". And then somewhere at the start do: import * as process from 'process'; window['process'] = process;

alehro avatar Nov 01 '22 14:11 alehro

I made a fork of this module, mostly because of this use of process. It uses queueMicrotask instead, which is very well supported these days: wait-your-turn.

voltrevo avatar Dec 20 '22 07:12 voltrevo