npm start error on FreeBSD 14.1
Closed this issue · 7 comments
espionage724@Spinesnap:~/Projects/2004Scape-Server/src $ cd ~/'Projects/2004Scape-Server/src' && npm start
> 2004scape@1.0.0 start
> npm i && npm run ts-loader src/lostcity/app.ts
> 2004scape@1.0.0 prepare
> husky
up to date, audited 749 packages in 975ms
150 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
> 2004scape@1.0.0 ts-loader
> node --import @swc-node/register/esm-register --enable-source-maps --no-warnings src/lostcity/app.ts
node:internal/modules/run_main:129
triggerUncaughtException(
^
Error: Bindings not found.
at Compiler.<anonymous> (/home/espionage724/Projects/2004Scape-Server/src/node_modules/@swc/core/index.js:228:19)
at Generator.next (<anonymous>)
at /home/espionage724/Projects/2004Scape-Server/src/node_modules/@swc/core/index.js:34:71
at new Promise (<anonymous>)
at __awaiter (/home/espionage724/Projects/2004Scape-Server/src/node_modules/@swc/core/index.js:30:12)
at Compiler.transform (/home/espionage724/Projects/2004Scape-Server/src/node_modules/@swc/core/index.js:205:16)
at transform (/home/espionage724/Projects/2004Scape-Server/src/node_modules/@swc/core/index.js:347:21)
at transform (/home/espionage724/Projects/2004Scape-Server/src/node_modules/@swc-node/core/index.ts:101:22)
at compile (/home/espionage724/Projects/2004Scape-Server/src/node_modules/@swc-node/register/register.ts:101:21)
at load (/home/espionage724/Projects/2004Scape-Server/src/node_modules/@swc-node/register/esm.mts:103:28)
Node.js v20.15.1
Tried with Node/npm 20 and 22 and OpenJDK 20 and 22.
Doing npm install @swc/core-freebsd-x64 seems to get something different:
node:internal/modules/run_main:129
triggerUncaughtException(
^
[Error: unknown field `keepImportAttributes`, expected one of `plugins`, `keepImportAssertions`, `cacheRoot` at line 1 column 530] {
code: 'InvalidArg'
}
Which seems related to swc-project/swc#7923 changing keepImportAttributes and keepImportAssertions?
Tried through Linuxemu with linux_base-rl9 (downloaded Linux prebuilt Node, added PATH/NODE envs) but it looks like it's running into a filesystem-related issue (guessing watch isn't implemented with the Linux layer on FreeBSD?):
> 2004scape@1.0.0 ts-loader
> node --import @swc-node/register/esm-register --enable-source-maps --no-warnings src/lostcity/app.ts
Starting world...
Loading game map: 676.127ms
World ready: http://localhost:8888
node:internal/fs/watchers:247
const error = new UVException({
^
Error: ENOSYS: function not implemented, watch '/home/espionage724/Projects/2004Scape-Server/src/data/src'
at FSWatcher.<computed> (node:internal/fs/watchers:247:19)
at Object.watch (node:fs:2468:36)
at Watcher.watchDirectories (file:///home/espionage724/Projects/2004Scape-Server/src/node_modules/watcher/dist/watcher.js:188:36)
at file:///home/espionage724/Projects/2004Scape-Server/src/node_modules/watcher/dist/watcher.js:229:51
at file:///home/espionage724/Projects/2004Scape-Server/src/node_modules/watcher/dist/watcher.js:118:23
at new Promise (<anonymous>)
at file:///home/espionage724/Projects/2004Scape-Server/src/node_modules/watcher/dist/watcher.js:117:41
Emitted 'error' event on Watcher instance at:
at Watcher.error (file:///home/espionage724/Projects/2004Scape-Server/src/node_modules/watcher/dist/watcher.js:57:21)
at Watcher.watchDirectories (file:///home/espionage724/Projects/2004Scape-Server/src/node_modules/watcher/dist/watcher.js:208:22)
at file:///home/espionage724/Projects/2004Scape-Server/src/node_modules/watcher/dist/watcher.js:229:51
[... lines matching original stack trace ...]
at file:///home/espionage724/Projects/2004Scape-Server/src/node_modules/watcher/dist/watcher.js:117:41 {
errno: -38,
syscall: 'watch',
code: 'ENOSYS',
path: '/home/espionage724/Projects/2004Scape-Server/src/data/src',
filename: '/home/espionage724/Projects/2004Scape-Server/src/data/src'
}
Node.js v22.8.0
Got some error about bcrypt I couldn't workaround with random install commands (save, swc, bcryptjs) with 32-bit Wine, but it almost worked there (node and Adoptium JDK win32 installed easy as-is).
I have some more ideas, but currently I'm still unsure of how to get 2004Scape server running on FreeBSD 14.1.
I'm out of ideas. It seems like there's something with ts-loader or another dep that when used on FreeBSD runs into the:
unknown field `keepImportAttributes`, expected one of `plugins`, `keepImportAssertions`, `cacheRoot`
error, which implies that something isn't updated with the new swc(?) change that changed ImportAttributes and ImportAssertions around.
npm packaging, dep/resolving, names/versions are all too-messy for me to understand confidently to try to force-install things and I couldn't really get anything outside of solving the initial bindings issue (and seemingly swc trying to use wasm for bindgen) with manually-installing @swc/core-freebsd-x64
- Running natively got
ImportAttributesvsImportAssertions - Running through Wine got issues related to
bcrypt - Running through Linux layer (c7 or rl9) got
ENOSYSerrors withFSWatcher
Anyone have anything about this?
I'm thinking this could be fixed on either 2004Scape's end or swc's. It sounds like with 2004Scape switching keepImportAttributes to keepImportAssertions just for FreeBSD could solve this quick, but I couldn't figure out how to do it that easily from a quick code search.
With the new no-dev-watcher branch I got it working from a 64-bit Wine prefix (Win10) on FreeBSD 14.1! (notes) I'm mostly fine with running 2004Scape like this :p
But native FreeBSD nodejs/npm still runs into this :
> 2004scape@1.0.0 ts-loader
> node --import @swc-node/register/esm-register --enable-source-maps --no-warnings src/lostcity/app.ts
node:internal/modules/run_main:129
triggerUncaughtException(
^
Error: Bindings not found.
at Compiler.<anonymous> (/home/espionage724/Projects/2004Scape-Server/src/node_modules/@swc/core/index.js:228:19)
at Generator.next (<anonymous>)
at /home/espionage724/Projects/2004Scape-Server/src/node_modules/@swc/core/index.js:34:71
at new Promise (<anonymous>)
at __awaiter (/home/espionage724/Projects/2004Scape-Server/src/node_modules/@swc/core/index.js:30:12)
at Compiler.transform (/home/espionage724/Projects/2004Scape-Server/src/node_modules/@swc/core/index.js:205:16)
at transform (/home/espionage724/Projects/2004Scape-Server/src/node_modules/@swc/core/index.js:347:21)
at transform (/home/espionage724/Projects/2004Scape-Server/src/node_modules/@swc-node/core/index.ts:101:22)
at compile (/home/espionage724/Projects/2004Scape-Server/src/node_modules/@swc-node/register/register.ts:101:21)
at load (/home/espionage724/Projects/2004Scape-Server/src/node_modules/@swc-node/register/esm.mts:103:28)
Node.js v20.15.1
npm verbose cwd /home/espionage724/Projects/2004Scape-Server/src
npm verbose os FreeBSD 14.1-RELEASE-p5
npm verbose node v20.15.1
npm verbose npm v10.8.1
npm verbose exit 1
npm verbose code 1
npm verbose cwd /home/espionage724/Projects/2004Scape-Server/src
npm verbose os FreeBSD 14.1-RELEASE-p5
npm verbose node v20.15.1
npm verbose npm v10.8.1
npm verbose exit 1
npm verbose code 1
Or this (after npm install @swc/core-freebsd-x64):
espionage724@Spinesnap:~/Projects/2004Scape-Server/src $ cd ~/'Projects/2004Scape-Server/src' && 'npm' start --verbose
npm verbose cli /usr/local/bin/node /usr/local/bin/npm
npm info using npm@10.8.1
npm info using node@v20.15.1
npm verbose title npm start
npm verbose argv "start" "--loglevel" "verbose"
npm verbose logfile logs-max:10 dir:/home/espionage724/.npm/_logs/2024-10-04T21_38_31_944Z-
npm verbose logfile /home/espionage724/.npm/_logs/2024-10-04T21_38_31_944Z-debug-0.log
> 2004scape@1.0.0 start
> npm i && npm run ts-loader src/lostcity/app.ts
npm verbose cli /usr/local/bin/node /usr/local/bin/npm
npm info using npm@10.8.1
npm info using node@v20.15.1
npm verbose title npm i
npm verbose argv "i"
npm verbose logfile logs-max:10 dir:/home/espionage724/.npm/_logs/2024-10-04T21_38_32_043Z-
npm verbose logfile /home/espionage724/.npm/_logs/2024-10-04T21_38_32_043Z-debug-0.log
npm verbose reify failed optional dependency /home/espionage724/Projects/2004Scape-Server/src/node_modules/fsevents
npm verbose reify failed optional dependency /home/espionage724/Projects/2004Scape-Server/src/node_modules/@swc/core-win32-x64-msvc
[bunch of repeated above failed optional dep reify lines snipped]
npm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/advisories/bulk 473ms
> 2004scape@1.0.0 prepare
> husky
up to date, audited 746 packages in 1s
151 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
npm verbose cwd /home/espionage724/Projects/2004Scape-Server/src
npm verbose os FreeBSD 14.1-RELEASE-p5
npm verbose node v20.15.1
npm verbose npm v10.8.1
npm verbose exit 0
npm info ok
npm verbose cli /usr/local/bin/node /usr/local/bin/npm
npm info using npm@10.8.1
npm info using node@v20.15.1
npm verbose title npm run ts-loader src/lostcity/app.ts
npm verbose argv "run" "ts-loader" "src/lostcity/app.ts"
npm verbose logfile logs-max:10 dir:/home/espionage724/.npm/_logs/2024-10-04T21_38_33_122Z-
npm verbose logfile /home/espionage724/.npm/_logs/2024-10-04T21_38_33_122Z-debug-0.log
> 2004scape@1.0.0 ts-loader
> node --import @swc-node/register/esm-register --enable-source-maps --no-warnings src/lostcity/app.ts
node:internal/modules/run_main:129
triggerUncaughtException(
^
[Error: unknown field `keepImportAttributes`, expected one of `plugins`, `keepImportAssertions`, `cacheRoot` at line 1 column 530] {
code: 'InvalidArg'
}
Node.js v20.15.1
npm verbose cwd /home/espionage724/Projects/2004Scape-Server/src
npm verbose os FreeBSD 14.1-RELEASE-p5
npm verbose node v20.15.1
npm verbose npm v10.8.1
npm verbose exit 1
npm verbose code 1
npm verbose cwd /home/espionage724/Projects/2004Scape-Server/src
npm verbose os FreeBSD 14.1-RELEASE-p5
npm verbose node v20.15.1
npm verbose npm v10.8.1
npm verbose exit 1
npm verbose code 1
I suspect installing @swc/core-freebsd-x64 here isn't ideal even though it solves the initial Bindings thing (I got the same InvalidArg message even on Termux on Android arm64 after installing its @swc/core Android package).
It sounds like swc/wasm could be used and also solves the Bindings message, but runs into something like:
Error: invalid type: unit value, expected struct Options
Resolved. Two changes helped here:
First, I rewrote the file watcher code to use native node APIs and that covered the error that was worked around by the no-dev-watcher branch.
Second, I switched us from SWC to TSX. TSX did have one headache to solve with workers but it's fine otherwise.