I am encountering an error when I go to start one of my Discord bots on my Raspberry Pi 3B.
/home/pi/Downloads/xx/xx/bot.js:301
if (channel?.messages.cache.has(packet.d.message_id)) return;
^
SyntaxError: Unexpected token '.'
at wrapSafe (internal/modules/cjs/loader.js:915:16)
at Module._compile (internal/modules/cjs/loader.js:963:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
at internal/main/run_main_module.js:17:47
When running the same bot on my main Windows 11 Machine, it runs perfectly fine.
NodeJS/NPM on both my main machine and my R-Pi are running v16.15.1. Is there any way I could fix this? Thank you in advance.
As mentioned on the nodejs.org website, you can install the latest versions with the NodeSource deb package:
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
# and then
sudo apt-get install -y nodejs
The default packages on your system are not up-to-date.
Good day
Related
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.
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.
I am trying to run 'node server.js' to connect my raspberry pi device to Azure via the Azure IoT Hub. When I run the command 'node server.js', I receive the following error. Please note that I replaced my computer's user name with 'username'. The file connection_string.js does not have my computer's username in it, despite the error saying that it does. Please see error below:
SyntaxError: Invalid flags supplied to RegExp constructor '*username*'
at new RegExp (native)
at Object.<anonymous> (/Users/*username*/iot-hub-c-raspberrypi-getstartedkit/command_center_node/node_modules/azure-iot-common/lib/connection_string.js:9:31)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/Users/*username*/iot-hub-c-raspberrypi-getstartedkit/command_center_node/node_modules/azure-iot-common/common.js:15:21)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/Users/*username*/iot-hub-c-raspberrypi-getstartedkit/command_center_node/server.js:7:15)
Thank you in advance for your help!
Not sure if it is your case or not, but I had similar issue:
SyntaxError: Invalid flags supplied to RegExp constructor 'u'
I fixed it simply by updating Node.js.
Previous version was:
$ node -v
v5.1.1
Then I did:
$ curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
... long output
$ sudo apt-get install -y nodejs
... shorter output
$ node -v
v6.7.0
And no more issues.
I am trying to start my node-red on a raspberry pi 2 using pm2. I am using the startup command:
pm2 start /usr/bin/node-red-pi --node-args="--max-old-space-size=128" -- -v
At first it seems to work:
But unfortunatly then it errors:
Thats the log:
SyntaxError: Unexpected token ILLEGAL
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:373:25)
at Object.Module._extensions..js (module.js:404:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Function._load (/usr/local/lib/node_modules/pm2/node_modules/pmx/lib/transaction.js:62:21)
at Object.<anonymous> (/usr/local/lib/node_modules/pm2/lib/ProcessContainerFork.js:28:21)
at Module._compile (module.js:397:26)
at Object.Module._extensions..js (module.js:404:10)
at Module.load (module.js:343:32)
Please make sure you installed the latest PM2 version (>2.x):
$ npm install pm2#latest -g
$ pm2 update
Then start node-red again, it should works as expected:
pm2 start node-red --node-args="--max-old-space-size=128" -- -v
I'm running Node.js server on Ubuntu 12.04. When I try to start server with node server.js I get
fs.js:438
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: EACCES, permission denied '/home/scadge/nodejs/server.js'
at Object.fs.openSync (fs.js:438:18)
at Object.fs.readFileSync (fs.js:289:15)
at Object.Module._extensions..js (module.js:473:44)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
I also tried sudo node server.js and sudo su followed by node server.js - in all cases I get the same error.
Try as below.
Its permission issue.
Open terminal
Go the project directory.
run chmod -R 777
On everything that is related with access denied can be fix with this.
Thank You.