Can't run discord bot (JavaScript) - node.js

I can't get the bot to run on the replit platform. I used the command node . and npm start. I am getting an error:
throw new Error(`Could not find fetch library. Install "node-fetch"/"undici" or define "fetch" in global scope!`);
^
Error: Could not find fetch library. Install "node-fetch"/"undici" or define "fetch" in global scope!
at getFetch (/home/runner/qwerty1/node_modules/youtube-sr/dist/mod.js:428:9)
at Object.<anonymous> (/home/runner/qwerty1/node_modules/youtube-sr/dist/mod.js:411:13)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/home/runner/qwerty1/node_modules/discord-player/lib/utils/Util.js:17:38)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/home/runner/qwerty1/node_modules/discord-player/lib/Player.js:18:32)
Anyone have any ideas on how to fix this?

It looks like the youtube-sr package is looking to use the fetch api, but there isn't a library installed to do this.
Try following the error message and install the undici package (which adds fetch support to node js)
npm i undici

Related

Tried to compile contract using hardhat but got error:- Error: The specified module could not be found

Error: The specified module could not be found.
\\?\C:\Users\Lenovo\Desktop\Hardhat\node_modules\#nomicfoundation\solidity-analyzer-win32-x64-msvc\solidity-analyzer.win32-x64-msvc.node
at Object.Module._extensions..node (node:internal/modules/cjs/loader:1210:18)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12)
at Module.require (node:internal/modules/cjs/loader:1028:19)
at Module.require (node:internal/modules/cjs/loader:1028:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (C:\Users\Lenovo\Desktop\Hardhat\node_modules\#nomicfoundation\solidity-analyzer\index.js:69:29)
at Module._compile (node:internal/modules/cjs/loader:1126:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1180:10)
at Module.load (node:internal/modules/cjs/loader:1004:32)
at Function.Module._load (node:internal/modules/cjs/loader:839:12) {
code: 'ERR_DLOPEN_FAILED'
}
Tried to compile but didnt get any result.It countain the specified modules but throws error.
Drag that specified module into that folder where all the other files are kept. Do the same with other modules till all the files required for the project are not under one folder.
This might help.
Thank You.

Node.JS Express loader:1183 Error on Raspberry Pi

I programmed a NodeJs Express backend on my PC and when I start it, everything works fine. Now I managed to install NodeJs and npm with the same versions as on my PC, on my Raspberry Pi with Raspbian Lite on it. Now I want to host my backend on it (just localy). First everything looks fine but after 5 seconds, this error appears:
node:internal/modules/cjs/loader:1183
return process.dlopen(module, path.toNamespacedPath(filename));
^
Error: /home/Raspbius/servers/humaster/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node: invalid ELF header
at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/home/Raspbius/servers/humaster/node_modules/bcrypt/bcrypt.js:6:16)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/home/Raspbius/servers/humaster/server.js:7:16)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32) {
code: 'ERR_DLOPEN_FAILED'
}
I have no clue how to solve it because on my PC everything works fine with the exact same package.
Thanks in advance!

node-mysql2: Object.entries is not a function

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.

Can't deploy my node.js app anymore on ubuntu

An old app at work stoped working on an aws machine. I've been assigned the task, but I'm more of a Rails guy. And this is node.js using an old Sails. I tried a bunch of stuff and now even my npm seem broken. I get this error:
ubuntu#ip-172-31-5-52:~$ npm -v
internal/modules/cjs/loader.js:605
throw err;
^
Error: Cannot find module 'are-we-there-yet'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
at Function.Module._load (internal/modules/cjs/loader.js:529:25)
at Module.require (internal/modules/cjs/loader.js:659:17)
at require (internal/modules/cjs/helpers.js:22:18)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npmlog/log.js:2:16)
at Module._compile (internal/modules/cjs/loader.js:723:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:734:10)
at Module.load (internal/modules/cjs/loader.js:620:32)
at tryModuleLoad (internal/modules/cjs/loader.js:560:12)
at Function.Module._load (internal/modules/cjs/loader.js:552:3)

OData, JayData, and node.js: Cannot find ExpressionVisitor.js

I ran npm install odata-server, but calling require('odata-server') fails with the following:
Using JayLint for code parsing
module.js:340
throw err;
^
Error: Cannot find module './Types/Expressions/Visitors/ExpressionVisitor.js'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (/home/anewman/node_modules/odata-server/lib/jaydata/lib/index.js:28:1)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:362:17)
Try to reinstall the module and check that the missing file is there. Please also check your NODE_PATH settings because the library can not find the acorn parser module under ~/node_modules/odata-server/lib/jaydata/node-modules/acorn

Resources