await-semaphore
await-semaphore copied to clipboard
Cannot find name 'process'
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'
same problem here.. Uncaught (in promise): ReferenceError: process is not defined
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.
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,
}),
],
};
};
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;
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
.