node-mysql2: Object.entries is not a function - node.js

I am trying to set up nodejs project on Hostgator. But while setting up I am getting the below error. Any help would be really appreciated.
My node version is 16.8.0 and the npm version is 7.21.0
/home/dir/project_folder/node_modules/mysql2/lib/packets/index.js:49
Object.entries(ctorMap).forEach(([name, ctor]) => {
^
TypeError: Object.entries is not a function
at Object.<anonymous> (/home/dir/project_folder/node_modules/mysql2/lib/packets/index.js:49:8)
at Module._compile (module.js:577:32)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/dir/project_folder/node_modules/mysql2/lib/connection.js:23:17)
at Module._compile (module.js:577:32)

It is working by replacing node mysql2 with mysql package.

Related

Getting error while hashing password with bcrypt: can not find module bcrypt_lib.node

I'm working on an api project with node.js and receive this error while trying to hash my code with bcrypt package :
throw err;
^
Error: Cannot find module '/home/emad/work/node.js/npm-demo/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node'
Require stack:
- /home/emad/work/node.js/npm-demo/node_modules/bcrypt/bcrypt.js
- /home/emad/work/node.js/npm-demo/routes/users.js
- /home/emad/work/node.js/npm-demo/index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/home/emad/work/node.js/npm-demo/node_modules/bcrypt/bcrypt.js:6:16)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/home/emad/work/node.js/npm-demo/routes/users.js:1:16)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32)
at Function.Module._load (internal/modules/cjs/loader.js:878:14)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/home/emad/work/node.js/npm-demo/index.js:8:14)
at Module._compile (internal/modules/cjs/loader.js:1137:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
at Module.load (internal/modules/cjs/loader.js:985:32) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/home/emad/work/node.js/npm-demo/node_modules/bcrypt/bcrypt.js',
'/home/emad/work/node.js/npm-demo/routes/users.js',
'/home/emad/work/node.js/npm-demo/index.js'
]
}
My OS is a Ubuntu 18.04.5 LTS and I installed all the dependecies that was written down in bcrypt page in npm site
try below steps and run:-
Delete node_modules folder
run npm cache clean --force
npm install

How to fix `Cannot find module ./logging/Logger` in Webpack-cli

When i tried webpack build using webpack-cli by jenkins, following error comes up.
I already tried yarn upgrade, global added webpack-cli..
but nothing happens.
Following code is got by jenkins.
/var/lib/jenkins/workspace/websdk (develop)/node_modules/webpack-cli/bin/cli.js:93
throw err;
^
Error: Cannot find module './logging/Logger'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (/var/lib/jenkins/workspace/websdk (develop)/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at Object.<anonymous> (/var/lib/jenkins/workspace/websdk (develop)/node_modules/webpack/lib/Stats.js:12:21)
at Module._compile (/var/lib/jenkins/workspace/websdk (develop)/node_modules/v8-compile-cache/v8-compile-cache.js:192: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 (/var/lib/jenkins/workspace/websdk (develop)/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at Object.<anonymous> (/var/lib/jenkins/workspace/websdk (develop)/node_modules/webpack/lib/Compilation.js:30:15)
at Module._compile (/var/lib/jenkins/workspace/websdk (develop)/node_modules/v8-compile-cache/v8-compile-cache.js:192: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 (/var/lib/jenkins/workspace/websdk (develop)/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at Object.<anonymous> (/var/lib/jenkins/workspace/websdk (develop)/node_modules/webpack/lib/Compiler.js:20:21)
at Module._compile (/var/lib/jenkins/workspace/websdk (develop)/node_modules/v8-compile-cache/v8-compile-cache.js:192: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 (/var/lib/jenkins/workspace/websdk (develop)/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at Object.<anonymous> (/var/lib/jenkins/workspace/websdk (develop)/node_modules/webpack/lib/webpack.js:7:18)
at Module._compile (/var/lib/jenkins/workspace/websdk (develop)/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Use npm install webpack in terminal and try

Cannot find module '#babel/runtime/core-js/object/create' Node js Express

I have an express project and its running perfectly on my local machine (Windows).
When i try to deploy it (on ubuntu), i am getting
Error: Cannot find module '#babel/runtime/core-js/object/create'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/var/www/project/node_modules/xregexp/lib/xregexp.js:10:38)
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.<anonymous> (/var/www/project/node_modules/xregexp/lib/index.js:10:39)
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.<anonymous> (/var/www/project/controllers/script.js:3:15)
at Module._compile (module.js:653:30)
I tried npm install babel-runtime --save but it didn't solve anything
hit this issue this morning as well. Are you by chance using xregexp? If so, lock the version to 4.2.0 in your package.json by removing any leading carrot. "xregexp": "4.2.0"
https://github.com/slevithan/xregexp/issues/262
Update: Looks like they have fixed it in 4.2.3.

Node js Watson Speech to text to console Not working

When I started app on windows I get this error:
Error: Module did not self-register.
at Object.Module._extensions..node (module.js:672:18)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\Users\ahmet\node_modules\line-in\index.js:2:20)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
I updated all modules
I updated node
I do everything but still this error

Loading GoCardless SDK with require not working

When I try and load the GoCardless SDK and appy the congfig as sated in the documentation nodejs throws me the following error:
var gocardless = require('gocardless')(gcConfig);
^
TypeError: require(...) is not a function
at Object.<anonymous> (/Users/joe/projects/adultcms-main-site/routes/views/register.js:10:39)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at /Users/joe/projects/adultcms-main-site/node_modules/keystone/lib/core/importer.js:42:23
at Array.forEach (native)
at importer (/Users/joe/projects/adultcms-main-site/node_modules/keystone/lib/core/importer.js:32:26)
at Object.<anonymous> (/Users/joe/projects/adultcms-main-site/routes/index.js:31:9)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (/Users/joe/projects/adultcms-main-site/keystone.js:58:24)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
Here is what the file looks like that includes the SDK.
var keystone = require('keystone');
var gcConfig = {
sandbox: true,
appId: process.env.appId,
appSecret: process.env.appSecret,
token: process.env.token,
merchantId: process.env.merchantId
};
var gocardless = require('gocardless')(gcConfig);
Well, 0.1.1 seems to be older version. That documentation seems to be for latest version https://www.npmjs.com/package/gocardless the latest version seems to be 1.0.0-beta6. For some reason though you seem to be getting older version of module. Can you check, what version of node and npm you have? Also you can try installing latest module with npm install gocardless#1.0.0-beta6

Resources