Dİscord.js on Linux - javascript

I was using Windows and now I switched to Linux. When using Windows, I was running my discord.js bot with the "node bot.js" command. I can't run this command on Linux. I created the bot ID again with the command "npm init" and made the test command "node bot.js" but again I get the error. I need your help. (Linux Mint 64 bit)
Error output: /home/blour/Desktop/ew/node_modules/discord.js/src/client/Client.js:41
} catch {
^
SyntaxError: Unexpected token {
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:616:28)
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/blour/Desktop/ew/node_modules/discord.js/src/index.js:8:11)

I assume from your error that you are trying to use a try/catch statement, you need to provide the catch part of the statement with an error parameter:
try {
// Do something
} catch (error) {
// Do something with 'error'
}

You have an incomplete try/catch statement. Go to that file and to that line, find a console.error in those brackets or something like that and add (error) (replace error with the object in console.error) just after catch and before {.

You have an old version of nodejs installed. To reinstall it to a newer one, use:
sudo apt-get purge --auto-remove nodejs
sudo apt-get update
sudo apt-get install build-essential libssl-dev
curl https://raw.githubusercontent.com/creationix/nvm/v0.16.1/install.sh | sh
source ~/.profile
nvm install 14.17.4

Related

clarification and support on 'ERR_DLOPEN_FAILED'

I'm new with code and apps either launching or trial. Recently I've been trying to set up a node on my mac terminal and experienced the below problems....
ironfish start
/usr/local/Cellar/ironfish/75/libexec/node_modules/bindings/bindings.js:121
throw e;
^
Error: The module '/usr/local/Cellar/ironfish/75/libexec/node_modules/segfault-handler/build/Release/segfault-handler.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 108. This version of Node.js requires
NODE_MODULE_VERSION 93. Please try re-compiling or re-installing
the module (for instance, using npm rebuild or npm install).
at Object.Module._extensions..node (node:internal/modules/cjs/loader:1249:18)
at Module.load (node:internal/modules/cjs/loader:1043:32)
at Function.Module._load (node:internal/modules/cjs/loader:878:12)
at Module.require (node:internal/modules/cjs/loader:1067:19)
at require (node:internal/modules/cjs/helpers:103:18)
at bindings (/usr/local/Cellar/ironfish/75/libexec/node_modules/bindings/bindings.js:112:48)
at Object. (/usr/local/Cellar/ironfish/75/libexec/node_modules/segfault-handler/index.js:3:37)
at Module._compile (node:internal/modules/cjs/loader:1165:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1219:10)
at Module.load (node:internal/modules/cjs/loader:1043:32) {
code: 'ERR_DLOPEN_FAILED'
}
I followed some solution similar to the err name but that didn't resolve it:
npm uninstall bcrypt
npm install bcryptjs
npm install bcrypt
it's not resolved. please assit

I have a better_sqlite3.node error when i require quick.db

i dont have errors when i install but when i require quick.db in my main.js (its a discord.js bot in v12)
const db = require('quick.db')
i have an better_sqlite3.node error in my terminal
-C:\Users\Fatsah\Desktop\Wizzy Bot\node_modules\bindings\bindings.js:121
throw e;
^
Error: The module '\\?\C:\Users\Fatsah\Desktop\Wizzy Bot\node_modules\better-sqlite3\build\Release\better_sqlite3.node'
was compiled against a different Node.js version using
NODE_MODULE_VERSION 83. This version of Node.js requires
NODE_MODULE_VERSION 93. Please try re-compiling or re-installing
the module (for instance, using `npm rebuild` or `npm install`).
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:94:18)
at bindings (C:\Users\Fatsah\Desktop\Wizzy Bot\node_modules\bindings\bindings.js:112:48)
at Object.<anonymous> (C:\Users\Fatsah\Desktop\Wizzy Bot\node_modules\better-sqlite3\lib\database.js:9:24)
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'
}
PS C:\Users\Fatsah\Desktop\Wizzy Bot>
i tried to reinstall and update node.js into the last test
Node version : v16.7.0
Discord.js : v12.5.3
Npm Version : 7.20.3
I have this error not long ago, when I was using node v14 and I have the same with canvas / canvacord but is canvas.node
Reinstall all your dependencies, you probably upgraded Node after you installed better-sqlite3 and you need to rebuild the library again.

FB CTF - SyntaxError: Grunt is not generating JS Files

Installing prod: https://github.com/facebookarchive/fbctf/wiki/Installation-Guide,-Production
This is the error message that I am getting when I try to install by any given method(direct,docker and vagrant):
[+] Running grunt to generate JS files
/var/www/fbctf/node_modules/grunt-legacy-log-utils/node_modules/chalk/source/index.js:106
...styles,
^^^
SyntaxError: Unexpected token ...
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
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> (/var/www/fbctf/node_modules/grunt-legacy-log-utils/index.js:12:13)
try it
-> # apt remove nodejs
-> # curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
-> # sudo apt-get install -y nodejs
Probably, if it is not version 12, an error appears
On Windows install the latest version of node.js and the error should disappear.
Was working on getting FBCTF up, tried to search everywhere but no one has a fix. Found a fix myself.
nano package.json
In package.json, change from
"grunt": "^1.0.1",
to
"grunt": "1.0.1",
The "^" seems to update the version of grunt to 1.3.0 (As of writing this) which apparently is not compatible with the FBCTF which have not been maintained for 2 years.

NPM: Cannot find module '../lib/utils/unsupported.js'

I'm getting the following error when trying to do anything with npm:
internal/modules/cjs/loader.js:638
throw err;
^
Error: Cannot find module '../lib/utils/unsupported.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at /usr/local/lib/node_modules/npm/bin/npm-cli.js:19:21
at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:153:3)
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:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
I can't run npx create-react-app or any npm commands including uninstalling or updating npm. Yesterday I installed yarn, could that be part of the problem? I also updated my Mac to Catalina 10.15.5 recently. I'm not sure if either/both of these caused the npm issue or not.
What's causing this and how can I fix it?
Found a solution. A modified version of this answer worked.
I ran:
brew uninstall --force node
sudo rm -r /usr/local/lib/node_modules
brew install node
and that did the trick.

How to fix Nodemon "async remove {}" syntax error?

Whenever I try to run nodemon to auto-restart my local server (running on port 3000), I get this error message regarding a syntax error in the no
/Users/SI23/.nvm/versions/node/v6.5.0/lib/node_modules/nodemon/node_modules/chokidar/index.js:151
async remove(item) {
^^^^^^
SyntaxError: Unexpected identifier
at Object.exports.runInThisContext (vm.js:76:16)
at Module._compile (module.js:528:28)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/Users/SI23/.nvm/versions/node/v6.5.0/lib/node_modules/nodemon/lib/monitor/watch.js:6:16)
at Module._compile (module.js:556:32)
Any way to fix this?
As per my knowledge
Async Await is not available in node v6.5.0,
which you are using. So you can upgrade your node version or can start using Promise object with the same version of node.
In my case, npm list chokidar helped me realize it was another module (gulp-nodemon) that used a newer version of chokidar. It worked after downgrading it.
I had exactly the same error...! it was a node version problem, I was on node version 6, this is what I did to fix it:
nvm install <VERSION_NUMBER> // nvm install 10.15.3
nvm use <VERSION_NUMBER> // nvm use 10.15.3
node -v // confirm i am using the correct version of node
Remember to do this on your computer not just your code file and change the default node version with nvm alias default 10.15.3
you can check your default lists with
nvm list

Categories

Resources