mayudev / revcord

A bridge for Discord and Revolt with easy setup through commands
MIT License
69 stars 12 forks source link

SyntaxError: Unexpected token '?' #6

Closed Apacelus closed 1 year ago

Apacelus commented 1 year ago

Running natively on a rpi (zero 2), after installing all npm deps, running the build and creating a .env file with the appropriate vars, I get this error:

$ npm start

> revcord@1.1.1 start
> node --experimental-specifier-resolution=node build/index.js

file:///home/pi/revcord/node_modules/@discordjs/rest/dist/index.mjs:1
var ne=Object.defineProperty;var ae=(n,e,t)=>e in n?ne(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var oe=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports);var l=(n,e,t)=>(ae(n,typeof e!="symbol"?e+"":e,t),t),Q=(n,e,t)=>{if(!e.has(n))throw TypeError("Cannot "+t)};var u=(n,e,t)=>(Q(n,e,"read from private field"),t?t.call(n):e.get(n)),L=(n,e,t)=>{if(e.has(n))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(n):e.set(n,t)},g=(n,e,t,s)=>(Q(n,e,"write to private field"),s?s.call(n,t):e.set(n,t),t);var Z=oe((we,le)=>{le.exports={name:"@discordjs/rest",version:"0.3.0",description:"The REST API for discord.js",scripts:{build:"tsup && tsc --emitDeclarationOnly --incremental",test:"jest --pass-with-no-tests --collect-coverage",lint:"prettier --check . && eslint src __tests__ --ext mjs,js,ts",format:"prettier --write . && eslint src __tests__ --ext mjs,js,ts --fix",docs:"typedoc --json docs/typedoc-out.json src/index.ts && node scripts/docs.mjs",prepublishOnly:"yarn build && yarn lint && yarn test",changelog:"git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/rest/*'"},main:"./dist/index.js",module:"./dist/index.mjs",typings:"./dist/index.d.ts",exports:{import:"./dist/index.mjs",require:"./dist/index.js"},directories:{lib:"src",test:"__tests__"},files:["dist"],contributors:["Crawl <icrawltogo@gmail.com>","Amish Shah <amishshah.2k@gmail.com>","SpaceEEC <spaceeec@yahoo.com>","Vlad Frangu <kingdgrizzle@gmail.com>","Antonio Roman <kyradiscord@gmail.com>"],license:"Apache-2.0",keywords:["discord","api","rest","discordapp","discordjs"],repository:{type:"git",url:"git+https://github.com/discordjs/discord.js.git"},bugs:{url:"https://github.com/discordjs/discord.js/issues"},homepage:"https://discord.js.org",dependencies:{"@discordjs/collection":"^0.4.0","@sapphire/async-queue":"^1.1.9","@sapphire/snowflake":"^3.0.1","discord-api-types":"^0.26.1","form-data":"^4.0.0","node-fetch":"^2.6.5",tslib:"^2.3.1"},devDependencies:{"@babel/core":"^7.16.12","@babel/plugin-proposal-decorators":"^7.16.7","@babel/preset-env":"^7.16.11","@babel/preset-typescript":"^7.16.7","@discordjs/ts-docgen":"^0.3.4","@types/jest":"^27.4.0","@types/node-fetch":"^2.5.10","@typescript-eslint/eslint-plugin":"^5.10.0","@typescript-eslint/parser":"^5.10.0","babel-plugin-const-enum":"^1.2.0","babel-plugin-transform-typescript-metadata":"^0.3.2",eslint:"^8.7.0","eslint-config-marine":"^9.3.2","eslint-config-prettier":"^8.3.0","eslint-plugin-prettier":"^4.0.0",jest:"^27.4.7",nock:"^13.2.2",prettier:"^2.5.1",tsup:"^5.11.11",typedoc:"^0.22.11",typescript:"^4.5.5"},engines:{node:">=16.9.0"},publishConfig:{access:"public"}}});import{APIVersion as ue}from"discord-api-types/v9";var V=Z(),Y=`DiscordBot (${V.homepage}, ${V.version})`,x={agent:{},api:"https://discord.com/api",cdn:"https://cdn.discordapp.com",headers:{},invalidRequestWarningInterval:0,globalRequestsPerSecond:50,offset:50,rejectOnRateLimit:null,retries:3,timeout:15e3,userAgentAppendix:`Node.js ${process.version}`,version:ue,hashSweepInterval:144e5,hashLifetime:864e5,handlerSweepInterval:36e5},j=(m=>(m.Debug="restDebug",m.InvalidRequestWarning="invalidRequestWarning",m.RateLimited="rateLimited",m.Request="request",m.Response="response",m.HashSweep="hashSweep",m.HandlerSweep="handlerSweep",m))(j||{}),ee=["webp","png","jpg","jpeg","gif"],te=["png","json"],_=[16,32,64,128,256,512,1024,2048,4096];var N=class{constructor(e=x.cdn){this.base=e}appAsset(e,t,s){return this.makeURL(`/app-assets/${e}/${t}`,s)}appIcon(e,t,s){return this.makeURL(`/app-icons/${e}/${t}`,s)}avatar(e,t,s){return this.dynamicMakeURL(`/avatars/${e}/${t}`,t,s)}banner(e,t,s){return this.dynamicMakeURL(`/banners/${e}/${t}`,t,s)}channelIcon(e,t,s){return this.makeURL(`/channel-icons/${e}/${t}`,s)}defaultAvatar(e){return this.makeURL(`/embed/avatars/${e}`)}discoverySplash(e,t,s){return this.makeURL(`/discovery-splashes/${e}/${t}`,s)}emoji(e,t){return this.makeURL(`/emojis/${e}`,{extension:t})}guildMemberAvatar(e,t,s,i){return this.dynamicMakeURL(`/guilds/${e}/users/${t}/avatars/${s}`,s,i)}icon(e,t,s){return this.dynamicMakeURL(`/icons/${e}/${t}`,t,s)}roleIcon(e,t,s){return this.makeURL(`/role-icons/${e}/${t}`,s)}splash(e,t,s){return this.makeURL(`/splashes/${e}/${t}`,s)}sticker(e,t){return this.makeURL(`/stickers/${e}`,{allowedExtensions:te,extension:t??"png"})}stickerPackBanner(e,t){return this.makeURL(`/app-assets/710982414301790216/store/${e}`,t)}teamIcon(e,t,s){return this.makeURL(`/team-icons/${e}/${t}`,s)}dynamicMakeURL(e,t,{forceStatic:s=!1,...i}={}){return this.makeURL(e,!s&&t.startsWith("a_")?{...i,extension:"gif"}:i)}makeURL(e,{allowedExtensions:t=ee,extension:s="webp",size:i}={}){if(s=String(s).toLowerCase(),!t.includes(s))throw new RangeError(`Invalid extension provided: ${s}

SyntaxError: Unexpected token '?'
    at Loader.moduleStrategy (internal/modules/esm/translators.js:133:18)
npm ERR! code 1
npm ERR! path /home/pi/revcord
npm ERR! command failed
npm ERR! command sh -c node --experimental-specifier-resolution=node build/index.js

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/pi/.npm/_logs/2023-02-06T15_47_43_229Z-debug.log
$ cat /home/pi/.npm/_logs/2023-02-06T15_47_43_229Z-debug.log
0 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ]
1 info using npm@7.5.2
2 info using node@v12.22.12
3 timing config:load:defaults Completed in 11ms
4 timing config:load:file:/usr/share/nodejs/npm/npmrc Completed in 12ms
5 timing config:load:builtin Completed in 12ms
6 timing config:load:cli Completed in 13ms
7 timing config:load:env Completed in 2ms
8 timing config:load:file:/home/pi/revcord/.npmrc Completed in 2ms
9 timing config:load:project Completed in 5ms
10 timing config:load:file:/home/pi/.npmrc Completed in 1ms
11 timing config:load:user Completed in 1ms
12 timing config:load:file:/etc/npmrc Completed in 0ms
13 timing config:load:global Completed in 1ms
14 timing config:load:cafile Completed in 2ms
15 timing config:load:validate Completed in 1ms
16 timing config:load:setUserAgent Completed in 3ms
17 timing config:load:setEnvs Completed in 7ms
18 timing config:load Completed in 61ms
19 verbose npm-session 6fa7f2462201e4b0
20 timing npm:load Completed in 125ms
21 timing command:run-script Completed in 1193ms
22 timing command:start Completed in 1209ms
23 verbose stack Error: command failed
23 verbose stack     at ChildProcess.<anonymous> (/usr/share/nodejs/@npmcli/promise-spawn/index.js:64:27)
23 verbose stack     at ChildProcess.emit (events.js:314:20)
23 verbose stack     at maybeClose (internal/child_process.js:1022:16)
23 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
24 verbose pkgid revcord@1.1.1
25 verbose cwd /home/pi/revcord
26 verbose Linux 5.15.61-v8+
27 verbose argv "/usr/bin/node" "/usr/bin/npm" "start"
28 verbose node v12.22.12
29 verbose npm  v7.5.2
30 error code 1
31 error path /home/pi/revcord
32 error command failed
33 error command sh -c node --experimental-specifier-resolution=node build/index.js
34 verbose exit 1
mayudev commented 1 year ago

Your node.js version is too old (v12.22.12). If you're using raspberry pi os, install node from another repo since the official one is too old

Apacelus commented 1 year ago

Oh, I see there was mention of it in the readme. Perhaps you could add a check somehow?

Apacelus commented 1 year ago

I updated to newer npm & nodejs packages on my rpi. Now when I run npm install inside the revcord dir, npm is just stuck at: (##################) ⠸ reify:typescript: timing reifyNode:node_modules/discord-api-types Completed in 34094ms Stuck for way too long (over an hour), but it does quit if I ctrl+c it.

Anyways, I decided to try this in an arch vm on my main computer (x86_64 based if it matters). Fully updated, clean arch vm, with the latest nodejs and npm packages. Throws a very long error after 30 seconds or so: error.log

mayudev commented 1 year ago

It seems the version of sqlite3 used by revcord was outdated, so I updated it in https://github.com/mayudev/revcord/commit/23f4c426d999f56c848d2667a4af2391784b4c6e and now it should use prebuilt binaries.

It should work on x86_64 now, but I'm still not sure about Raspberry Pi due to that. If it's stuck for a longer while again, try doing npm install sqlite3 --target_arch=arm64

Apacelus commented 1 year ago

Alright, thank you. This seems to work now.

I have noticed quite a few bugs. The bugs were rather easy to notice and the last commit was back in August 2022, so I am wondering if you are planning to further develop this project?

mayudev commented 1 year ago

Alright, thank you. This seems to work now.

I have noticed quite a few bugs. The bugs were rather easy to notice and the last commit was back in August 2022, so I am wondering if you are planning to further develop this project?

Yup, I haven't had time to work on it recently and I don't use Revolt as much as I used to, but if you want to submit a pull request or report the bug, feel free to and I'll take care of it sooner or later.