Testcafe / Jenkins job failing TypeError [ERR_INVALID_ARG_TYPE]: The "original" argument must be of type function. Received undefined - node.js

I have a jenkins job that has worked consistently for the past 2 years running various front end tests, but recently I've gotten a stack trace from the job in jenkins that is continuously failing where I'm unsure what to do to fix it. The stack trace is listed below from the job:
TypeError [ERR_INVALID_ARG_TYPE]: The "original" argument must be of type function. Received undefined
at promisify (internal/util.js:279:11)
at Object.<anonymous> (/home/ec2-user/workspace/Sandbox_Verify/node_modules/testcafe-safe-storage/lib/file.js:18:33)
at Module._compile (internal/modules/cjs/loader.js:1076:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:941:32)
at Function.Module._load (internal/modules/cjs/loader.js:782:14)
at Module.require (internal/modules/cjs/loader.js:965:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/home/ec2-user/workspace/Sandbox_Verify/node_modules/testcafe-safe-storage/lib/index.js:30:19)
at Module._compile (internal/modules/cjs/loader.js:1076:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
at Module.load (internal/modules/cjs/loader.js:941:32)
at Function.Module._load (internal/modules/cjs/loader.js:782:14)
at Module.require (internal/modules/cjs/loader.js:965:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (/home/ec2-user/workspace/Sandbox_Verify/node_modules/testcafe/lib/dashboard/config-storage.js:3:33) {
code: 'ERR_INVALID_ARG_TYPE'
}

I am facing the same issue. Looks like there was a latest version of testCafe 1.19.0 version released yesterday after which the issue started. If you change your testcafe version to "testcafe": "1.18.6" or remove the ^ it should work. Or may be need to upgrade the nodejs version being used. Got the below warning
npm WARN notsup Unsupported engine for testcafe#1.19.0: wanted: {"node":">=14.0.0"} (current: {"node":"10.24.1","npm":"6.14.12"})

This is due to the testcafe global version. I think
you can check the global version by testcafe --version
and confirm your project installed version -> you can check your package.json file
If both are mismatch means, this issue could occur. So you should set BOTH version to be same
Ex: npm i -g testcafe#1.18.6
In package.json --> testcafe": "^1.18.6
in my case, its works perfectly. and also I have used firefox:headless

The cause of the issue is that you are using an outdated Node.js version.
The crypto.randomUUID function doesn't exist in Node.js 10.24.1.
Please update it to 14.x and all will work correctly.

Related

Error while trying to deploy page - npm errors

I am trying to deploy my github page on Cloudfare and I am getting a bunch of errors. I tried installing lating versions od npm and node.js but I really dont understand what I need to do to fix them. Also, looked in my package.json file and I dont have a script for a build. Do I add one, and if so, what do I add to the scripts section? Here is the error message:
ERROR: npm v9.4.2 is known not to run on Node.js v12.18.0. You'll need to upgrade
07:11:10.568 to a newer Node.js version in order to use this version of npm. This version of
07:11:10.569 npm supports the following node versions: ^14.17.0 || ^16.13.0 || >=18.0.0. You
07:11:10.569 can find the latest version at https://nodejs.org/.
07:11:10.569
07:11:10.569 ERROR:
07:11:10.569 /opt/buildhome/repo/node_modules/npm/lib/utils/exit-handler.js:21
07:11:10.570 const hasLoadedNpm = npm?.config.loaded
07:11:10.570 ^
07:11:10.570
07:11:10.570 SyntaxError: Unexpected token '.'
07:11:10.570 at wrapSafe (internal/modules/cjs/loader.js:1054:16)
07:11:10.570 at Module._compile (internal/modules/cjs/loader.js:1102:27)
07:11:10.570 at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
07:11:10.570 at Module.load (internal/modules/cjs/loader.js:986:32)
07:11:10.570 at Function.Module._load (internal/modules/cjs/loader.js:879:14)
07:11:10.571 at Module.require (internal/modules/cjs/loader.js:1026:19)
07:11:10.571 at require (internal/modules/cjs/helpers.js:72:18)
07:11:10.571 at module.exports (/opt/buildhome/repo/node_modules/npm/lib/cli.js:81:23)
07:11:10.571 at Object. (/opt/buildhome/repo/node_modules/npm/bin/npm-cli.js:2:25)
07:11:10.571 at Module._compile (internal/modules/cjs/loader.js:1138:30)
07:11:10.577 Failed: build command exited with code: 1
07:11:11.469 Failed: an internal error occurred
I tried installing latest versions of npm and node.js and waas expecting it to be updated but i am getting the same error.

How to solve this 'SyntaxError: Invalid regular expression' in pm2

I install node.js with pm2, all install fine but when i try to do pm2 monit give me this error.
$ pm2 monit
/home/node/.nvm/versions/node/v8.11.3/lib/node_modules/pm2/node_modules/fast-printf/dist/src/tokenize.js:4
const TokenRule = /(?:%(?<flag>([+0-]|-\+))?(?<width>\d+)?(?<position>\d+\$)?(?<precision>\.\d+)?(?<conversion>[%BCESb-iosux]))|(\\%)/g;
^
SyntaxError: Invalid regular expression: /(?:%(?<flag>([+0-]|-\+))?(?<width>\d+)?(?<position>\d+\$)?(?<precision>\.\d+)?(?<conversion>[%BCESb-iosux]))|(\\%)/: Invalid group
at Object.<anonymous> (/home/node/.nvm/versions/node/v8.11.3/lib/node_modules/pm2/node_modules/fast-printf/dist/src/tokenize.js:4:19)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/home/node/.nvm/versions/node/v8.11.3/lib/node_modules/pm2/node_modules/fast-printf/dist/src/createPrintf.js:5:20)
at Module._compile (module.js:652:30)
I tried servers nodejs version and always give me this error.
If you paste your regular expression into a regex sandbox, like this one:
https://regex101.com/r/GkwWH2/1
You'll see that it doesn't show any syntax errors.
That would make me suspect that you're running a back-level version of Node JS. And in fact, if you look at your stack trace, you see that you are running Node 8.11.3
at Object.<anonymous> (/home/node/.nvm/versions/node/v8.11.3/lib/node_modules/pm2/node_modules/fas
That regular expression is using features (such as named capture groups) that did not come into Node.js until Node v10.*.
I suggest you update to the latest LTS version of Node, version 14.*: from your stack trace it would appear that you're using NVM, so it should be a simple matter of
sudo nvm install lts/fermium
should do it.

Adonis 5 node deprecated warning when using migration

This has recently started poping up in commandline....anyone know whats going on, Im unsure why the new package in node_modules is not compatable with node v14.16. I tried using older version of node (docs state min version for adonis 5 is version 12), although this produces a syntax error.
This container.with() is deprecated warning shows whenever using the node ace commands. How can I fix these?
Node version 14.16.0:
node --trace-warnings ace migration:rollback
(node:24088) container.with() is deprecated. Use container.withBindings() instead: DeprecationWarning
at Ioc.with (C:\project\node_modules\#adonisjs\fold\build\src\Ioc\index.js:421:17)
at DatabaseServiceProvider.registerHealthChecker (C:\project\node_modules\#adonisjs\lucid\build\providers\DatabaseProvider.js:93:32)
at DatabaseServiceProvider.boot (C:\project\node_modules\#adonisjs\lucid\build\providers\DatabaseProvider.js:140:14)
at Registrar.boot (C:\project\node_modules\#adonisjs\fold\build\src\Registrar\index.js:116:32)
at C:\project\node_modules\#adonisjs\application\build\src\Application.js:543:13
at Profiler.profileAsync (C:\project\node_modules\#adonisjs\application\node_modules\#adonisjs\profiler\build\src\Profiler\AbstractProfiler.js:20:32)
at Application.bootProviders (C:\project\node_modules\#adonisjs\application\build\src\Application.js:541:9)
at App.wire (C:\project\node_modules\#adonisjs\core\build\src\Ignitor\Ace\App\index.js:192:9)
at App.onFind (C:\project\node_modules\#adonisjs\core\build\src\Ignitor\Ace\App\index.js:145:13)
at Hooks.execute (C:\project\node_modules\#adonisjs\ace\build\src\Hooks\index.js:44:13)
(node:24088) container.with() is deprecated. Use container.withBindings() instead: DeprecationWarning
at Ioc.with (C:\project\node_modules\#adonisjs\fold\build\src\Ioc\index.js:421:17)
at DatabaseServiceProvider.defineValidationRules (C:\project\node_modules\#adonisjs\lucid\build\providers\DatabaseProvider.js:109:32)
at DatabaseServiceProvider.boot (C:\project\node_modules\#adonisjs\lucid\build\providers\DatabaseProvider.js:141:14)
at Registrar.boot (C:\project\node_modules\#adonisjs\fold\build\src\Registrar\index.js:116:32)
at C:\project\node_modules\#adonisjs\application\build\src\Application.js:543:13
at Profiler.profileAsync (C:\project\node_modules\#adonisjs\application\node_modules\#adonisjs\profiler\build\src\Profiler\AbstractProfiler.js:20:32)
at Application.bootProviders (C:\project\node_modules\#adonisjs\application\build\src\Application.js:541:9)
at App.wire (C:\project\node_modules\#adonisjs\core\build\src\Ignitor\Ace\App\index.js:192:9)
at App.onFind (C:\project\node_modules\#adonisjs\core\build\src\Ignitor\Ace\App\index.js:145:13)
at Hooks.execute (C:\project\node_modules\#adonisjs\ace\build\src\Hooks\index.js:44:13)
(node:24088) container.with() is deprecated. Use container.withBindings() instead: DeprecationWarning
at Ioc.with (C:\project\node_modules\#adonisjs\fold\build\src\Ioc\index.js:421:17)
at AuthProvider.boot (C:\project\node_modules\#adonisjs\auth\build\providers\AuthProvider.js:32:40)
at Registrar.boot (C:\project\node_modules\#adonisjs\fold\build\src\Registrar\index.js:116:32)
at C:\project\node_modules\#adonisjs\application\build\src\Application.js:543:13
at Profiler.profileAsync (C:\project\node_modules\#adonisjs\application\node_modules\#adonisjs\profiler\build\src\Profiler\AbstractProfiler.js:20:32)
at Application.bootProviders (C:\project\node_modules\#adonisjs\application\build\src\Application.js:541:9)
at App.wire (C:\project\node_modules\#adonisjs\core\build\src\Ignitor\Ace\App\index.js:192:9)
at App.onFind (C:\project\node_modules\#adonisjs\core\build\src\Ignitor\Ace\App\index.js:145:13)
at Hooks.execute (C:\project\node_modules\#adonisjs\ace\build\src\Hooks\index.js:44:13)
at Kernel.find (C:\project\node_modules\#adonisjs\ace\build\src\Kernel\index.js:371:13)
(node:24088) container.with() is deprecated. Use container.withBindings() instead: DeprecationWarning
at Ioc.with (C:\project\node_modules\#adonisjs\fold\build\src\Ioc\index.js:421:17)
at AuthProvider.boot (C:\project\node_modules\#adonisjs\auth\build\providers\AuthProvider.js:37:40)
at Registrar.boot (C:\project\node_modules\#adonisjs\fold\build\src\Registrar\index.js:116:32)
at C:\project\node_modules\#adonisjs\application\build\src\Application.js:543:13
at Profiler.profileAsync (C:\project\node_modules\#adonisjs\application\node_modules\#adonisjs\profiler\build\src\Profiler\AbstractProfiler.js:20:32)
at Application.bootProviders (C:\project\node_modules\#adonisjs\application\build\src\Application.js:541:9)
at App.wire (C:\project\node_modules\#adonisjs\core\build\src\Ignitor\Ace\App\index.js:192:9)
at App.onFind (C:\project\node_modules\#adonisjs\core\build\src\Ignitor\Ace\App\index.js:145:13)
at Hooks.execute (C:\project\node_modules\#adonisjs\ace\build\src\Hooks\index.js:44:13)
at Kernel.find (C:\project\node_modules\#adonisjs\ace\build\src\Kernel\index.js:371:13)
Node version 12.5.0:
node ace migration:rollback
C:\project\node_modules\#poppinss\utils\build\src\Helpers\string.js:241
return `${values[0]}${options?.pairSeparator || ' and '}${values[1]}`;
^
SyntaxError: Unexpected token .
at Module._compile (internal/modules/cjs/loader.js:720:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:643:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Module.require (internal/modules/cjs/loader.js:683:19)
at require (internal/modules/cjs/helpers.js:16:16)
at Object.<anonymous> (C:\project\node_modules\#poppinss\utils\build\src\Helpers\index.js:56:31)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:643:32)
Looks like after updating to latest 'release' version of adonis 5 this issue has been resolved. Stupid preview issues
#poppinss\utils\build\src\Helpers\string.js:241 uses optional chaining which is only supported from Node.js 14
Using Node.js v14.15 will fix the problem.
I personally had this problem with Node.js 12 and Node.js 14.16. I switched to Node.js v14.15.1 and it worked instantly.
It's the Lucid package. Running npm i #adonisjs/lucid#latest solves the issue.

internal modules cjs is not working after yarn upgraded to 1.13.0

I have a react app which is based on react boilerplate. I am running the
following command:
cross-env NODE_ENV=development node --experimental-modules ./server/index.mjs
After upgrading yarn to 1.13.0, I am getting the following error:
(node:11137) ExperimentalWarning: The ESM module loader is experimental.
internal/modules/cjs/loader.js:677
module.reflect.onReady((reflect) => {
^
TypeError: Cannot read property 'onReady' of undefined
at Module.load (internal/modules/cjs/loader.js:677:22)
at tryModuleLoad (internal/modules/cjs/loader.js:606:12)
at Function.Module._load (internal/modules/cjs/loader.js:598:3)
at Module.require (internal/modules/cjs/loader.js:705:19)
at require (internal/modules/cjs/helpers.js:14:16)
at Object.<anonymous> (/Users/mdjahidulislam/workspace/ifs/frontend/node_modules/psl/index.js:14:19)
at Module._compile (internal/modules/cjs/loader.js:799:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:810:10)
at Module.load (internal/modules/cjs/loader.js:666:32)
at tryModuleLoad (internal/modules/cjs/loader.js:606:12)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Seems like module.reflect is undefined. In which scenario it can be undefined and how I can solve the problem.
Thanks in advance for any help and suggestions.
Finally solved it. It was all about nodejs version. I had nodejs version 11.* and then I downgraded it on 10.* and it solved the issue.

Node + Coffeescript + Zappa

I have been looking around for the best framework with nodejs. I am starting to lean twords Zappa. I was testing it out and everything was working fine until I started a new project and reinstalled it with npm.
Now any time I do anything with it, it throws this error.
This
require('zappa') ->
console.log "Hello World!"
Becomes
TypeError: Cannot read property 'prototype' of undefined
at Object.<anonymous> (/home/giodamelio/Projects/node-boilerplate/node_modules/zappa/lib/zappa.js:65:15)
at Object.<anonymous> (/home/giodamelio/Projects/node-boilerplate/node_modules/zappa/lib/zappa.js:702:4)
at Module._compile (module.js:446:26)
at Object..js (module.js:464:10)
at Module.load (module.js:353:31)
at Function._load (module.js:311:12)
at Module.require (module.js:359:17)
at require (module.js:375:17)
at Object.<anonymous> (/home/giodamelio/Projects/node-boilerplate/src/app.coffee:3:3)
at Object.<anonymous> (/home/giodamelio/Projects/node-boilerplate/src/app.coffee:52:4)
What happened?
Recently I just had a similar problem with zappa 0.3.3
Apparently the creator of zappa is on vacation and doesn't update to the current versions of node.js, but you may use zappajs instead. It's a fork that is a little more up-to-date.
npm install zappajs
And use require('zappajs') instead of require('zappa').

Resources