karma icon indicating copy to clipboard operation
karma copied to clipboard

throw Error(yargs parser supports a minimum Node.js version of ${minNodeVersion} Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);

Open Ragunath opened this issue 5 months ago • 3 comments

I am in Angular 12 version , Node : 14.20.1. We upgraded angular 11 to angular 12 while running npm run test, then we faced this issue. Also, given the package .json below.

I tried changing many node versions even to the latest(20.x) as error described , no luck!

When karma is more than 6 version i.e "karma": "^6.3.12", karma-typescript": "~5.5.4",

====ERROR====== C:\Users\Project\node_modules\karma\node_modules\yargs-parser\build\index.cjs:1007 throw Error(yargs parser supports a minimum Node.js version of ${minNodeVersion}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions); ^

Error: yargs parser supports a minimum Node.js version of 10. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions at Object. (C:\Project\node_modules\karma\node_modules\yargs-parser\build\index.cjs:1007:15) at Module._compile (module.js:653:30) at Object.Module._extensions..js (module.js:664:10) at Module.load (module.js:566:32) at tryModuleLoad (module.js:506:12) at Function.Module._load (module.js:498:3) at Module.require (module.js:597:17) at require (internal/module.js:11:18) at Object. (C:\Project\node_modules\karma\node_modules\yargs\build\index.cjs:2855:16) at Module._compile (module.js:653:30) npm ERR! Test failed. See above for more details. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! @[email protected] prepublishOnly: npm run build:clean && npm test && npm run build:lib && npm run docs npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the @[email protected] prepublishOnly script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

========= I tried to fix in another angle by changing the versions of karma and its dependency packages. This time we are getting some other issue that can't track it. below are the error.

When karma is less than 5 version i.e "karma": "5.2.3", karma-typescript": "^4.1.1

====ERROR====== ERROR [karma-server]: UncaughtException:: Unable to resolve module [set] from [C:/Users/Project/lib.js] { "basedir": "C:/Users/project", "extensions": [ "extensions": [ ".js", ".json", ".ts", ".tsx" ], "moduleDirectory": [ "node_modules" ], "modules": { "assert": "C:\Users\Project\\node_modules\karma-typescript\node_modules\assert\build\assert.js", "buffer": "C:\Users\Project\\node_modules\buffer\index.js", "child_process": "C:\Users\Project\\node_modules\karma-typescript\dist\bundler\resolve\empty.js", "cluster": "C:\Users\Project\\node_modules\karma-typescript\dist\bundler\resolve\empty.js", "console": "C:\Users\Project\\node_modules\console-browserify\index.js", "constants": "C:\Users\Project\\node_modules\constants-browserify\constants.json", "crypto": "C:\Users\Project\\node_modules\crypto-browserify\index.js", "dgram": "C:\Users\Project\\node_modules\karma-typescript\dist\bundler\resolve\empty.js", "dns": "C:\Users\Project\\node_modules\karma-typescript\dist\bundler\resolve\empty.js", "domain": "C:\Users\Project\\node_modules\karma-typescript\node_modules\domain-browser\source\index.js", "events": "C:\Users\Project\\node_modules\karma-typescript\node_modules\events\events.js", "fs": "C:\Users\Project\\node_modules\karma-typescript\dist\bundler\resolve\empty.js", "http": "C:\Users\Project\\node_modules\karma-typescript\node_modules\stream-http\index.js", "https": "C:\Users\Project\\node_modules\https-browserify\index.js", "module": "C:\Users\Project\\node_modules\karma-typescript\dist\bundler\resolve\empty.js", "net": "C:\Users\Project\\node_modules\karma-typescript\dist\bundler\resolve\empty.js", "os": "C:\Users\Project\\node_modules\os-browserify\browser.js", "path": "C:\Users\Project\\node_modules\karma-typescript\node_modules\path-browserify\index.js", "punycode": "C:\Users\Project\\node_modules\karma-typescript\node_modules\punycode\punycode.js", "querystring": "C:\Users\Project\\node_modules\querystring-es3\index.js", "readline": "C:\Users\Project\\node_modules\karma-typescript\dist\bundler\resolve\empty.js", "repl": "C:\Users\Project\\node_modules\karma-typescript\dist\bundler\resolve\empty.js", "stream": "C:\Users\Project\\node_modules\stream-browserify\index.js", "_stream_duplex": "C:\Users\Project\\node_modules\karma-typescript\node_modules\readable-stream\lib\_stream_duplex.js", "_stream_passthrough": "C:\Users\Project\\node_modules\karma-typescript\node_modules\readable-stream\lib\_stream_passthrough.js", "_stream_readable": "C:\Users\Project\\node_modules\karma-typescript\node_modules\readable-stream\lib\_stream_readable.js", "_stream_transform": "C:\Users\Project\\node_modules\karma-typescript\node_modules\readable-stream\lib\_stream_transform.js", "_stream_writable": "C:\Users\Project\\node_modules\karma-typescript\node_modules\readable-stream\lib\_stream_writable.js", "string_decoder": "C:\Users\Project\\node_modules\karma-typescript\node_modules\string_decoder\lib\string_decoder.js", "sys": "C:\Users\Project\\node_modules\karma-typescript\node_modules\util\util.js", "timers": "C:\Users\Project\\node_modules\karma-typescript\node_modules\timers-browserify\main.js", "tls": "C:\Users\Project\\node_modules\karma-typescript\dist\bundler\resolve\empty.js", "tty": "C:\Users\Project\\node_modules\tty-browserify\index.js", "url": "C:\Users\Project\\node_modules\url\url.js", "util": "C:\Users\Project\\node_modules\karma-typescript\node_modules\util\util.js", "vm": "C:\Users\Project\\node_modules\karma-typescript\node_modules\vm-browserify\index.js", "zlib": "C:\Users\Project\\node_modules\browserify-zlib\lib\index.js", "_process": "C:\Users\Project\\node_modules\process\browser.js" }, "filename": "", "paths": [] } Error: Cannot find module 'set' from 'C:/Users/Project' 19 02 2024 13:06:56.945:ERROR [karma-server]: Error: Unable to resolve module [set] from [C:/Users/Project/lib.js] { "basedir": "C:/Users/Project", "extensions": [ ".js", ".json", ".ts", ".tsx" ], "moduleDirectory": [ "node_modules" ], "modules": { "assert": "C:\Users\Project\\node_modules\karma-typescript\node_modules\assert\build\assert.js", "buffer": "C:\Users\Project\\node_modules\buffer\index.js", "child_process": "C:\Users\Project\\node_modules\karma-typescript\dist\bundler\resolve\empty.js", "cluster": "C:\Users\Project\\node_modules\karma-typescript\dist\bundler\resolve\empty.js", "console": "C:\Users\Project\\node_modules\console-browserify\index.js", "constants": "C:\Users\Project\\node_modules\constants-browserify\constants.json", "crypto": "C:\Users\Project\\node_modules\crypto-browserify\index.js", "dgram": "C:\Users\Project\\node_modules\karma-typescript\dist\bundler\resolve\empty.js", "dns": "C:\Users\Project\\node_modules\karma-typescript\dist\bundler\resolve\empty.js", "domain": "C:\Users\Project\\node_modules\karma-typescript\node_modules\domain-browser\source\index.js", "events": "C:\Users\Project\\node_modules\karma-typescript\node_modules\events\events.js", "fs": "C:\Users\Project\\node_modules\karma-typescript\dist\bundler\resolve\empty.js", "http": "C:\Users\Project\\node_modules\karma-typescript\node_modules\stream-http\index.js", "https": "C:\Users\Project\\node_modules\https-browserify\index.js", "module": "C:\Users\Project\\node_modules\karma-typescript\dist\bundler\resolve\empty.js", "net": "C:\Users\Project\\node_modules\karma-typescript\dist\bundler\resolve\empty.js", "os": "C:\Users\Project\\node_modules\os-browserify\browser.js", "path": "C:\Users\Project\\node_modules\karma-typescript\node_modules\path-browserify\index.js", "punycode": "C:\Users\Project\\node_modules\karma-typescript\node_modules\punycode\punycode.js", "querystring": "C:\Users\Project\\node_modules\querystring-es3\index.js", "readline": "C:\Users\Project\\node_modules\karma-typescript\dist\bundler\resolve\empty.js", "repl": "C:\Users\Project\\node_modules\karma-typescript\dist\bundler\resolve\empty.js", "stream": "C:\Users\Project\\node_modules\stream-browserify\index.js", "_stream_duplex": "C:\Users\Project\\node_modules\karma-typescript\node_modules\readable-stream\lib\_stream_duplex.js", "_stream_passthrough": "C:\Users\Project\\node_modules\karma-typescript\node_modules\readable-stream\lib\_stream_passthrough.js", "_stream_readable": "C:\Users\Project\\node_modules\karma-typescript\node_modules\readable-stream\lib\_stream_readable.js", "_stream_transform": "C:\Users\Project\\node_modules\karma-typescript\node_modules\readable-stream\lib\_stream_transform.js", "_stream_writable": "C:\Users\Project\\node_modules\karma-typescript\node_modules\readable-stream\lib\_stream_writable.js", "string_decoder": "C:\Users\Project\\node_modules\karma-typescript\node_modules\string_decoder\lib\string_decoder.js", "sys": "C:\Users\Project\\node_modules\karma-typescript\node_modules\util\util.js", "timers": "C:\Users\Project\\node_modules\karma-typescript\node_modules\timers-browserify\main.js", "tls": "C:\Users\Project\node_modules\karma-typescript\dist\bundler\resolve\empty.js", "tty": "C:\Users\Project\node_modules\tty-browserify\index.js", "url": "C:\Users\Project\node_modules\url\url.js", "util": "C:\Users\Project\node_modules\karma-typescript\node_modules\util\util.js", "vm": "C:\Users\Project\node_modules\karma-typescript\node_modules\vm-browserify\index.js", "zlib": "C:\Users\Project\node_modules\browserify-zlib\lib\index.js", "_process": "C:\Users\Project\node_modules\process\browser.js" }, "filename": "", "paths": [] } Error: Cannot find module 'set' from 'C:/Users/Project' at C:/Users/Project\node_modules\karma-typescript\dist\bundler\resolve\resolver.js:178:27 at C:/Users/Project\node_modules\browser-resolve\index.js:265:24 at C:/Users/Project\node_modules\browser-resolve\node_modules\resolve\lib\async.js:46:14 at process (C:/Users/Project\node_modules\browser-resolve\node_modules\resolve\lib\async.js:173:43) at ondir (C:/Users/Project\node_modules\browser-resolve\node_modules\resolve\lib\async.js:188:17) at load (C:/Users/Project\node_modules\browser-resolve\node_modules\resolve\lib\async.js:69:43) at onex (C:/Users/Project\node_modules\browser-resolve\node_modules\resolve\lib\async.js:92:31) at C:/Users/Project\node_modules\browser-resolve\node_modules\resolve\lib\async.js:22:47 at FSReqWrap.oncomplete (fs.js:152:21) (node:27540) [log4js-node-DEP0004] DeprecationWarning: Pattern %d{DATE} is deprecated due to the confusion it causes when used. Please use %d{DATETIME} instead. (node:27540) [log4js-node-DEP0004] DeprecationWarning: Pattern %d{DATE} is deprecated due to the confusion it causes when used. Please use %d{DATETIME} instead. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! @Project test: karma start karma.conf.js --single-run=true npm ERR! Exit status 1 npm ERR! npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

stuck in this issue for more than 2 weeks, Any solution much appreciated, Thanks in advance.

Ragunath avatar Feb 20 '24 07:02 Ragunath

Were you able to find a resolution to this issue?

adeopura4 avatar Mar 29 '24 16:03 adeopura4

I've not been able to find out what causes it, but to prevent the error from throwing you can manually set process.env.YARGS_MIN_NODE_VERSION to something higher than what you're running with. See https://github.com/yargs/yargs-parser/blob/main/lib/index.ts#L19

royscheepens avatar Apr 10 '24 09:04 royscheepens

In our case we are using an old version of gulp that uses yargs parser as a dependency. We solved the issue by selecting the needed gulp tag in the pipelines.

npm i -g --quiet [email protected]

aahmadts avatar May 03 '24 14:05 aahmadts