etherpad-lite icon indicating copy to clipboard operation
etherpad-lite copied to clipboard

Unknown file extension ".ts" for server.ts

Open meaz opened this issue 1 year ago • 9 comments

Describe the bug When running etherpad, I get Unknown file extension ".ts" for /path/to/etherpad-lite/src/node/server.ts

To Reproduce Steps to reproduce the behavior:

  1. Install Git and Node.js
  2. Git clone repo
  3. Run bin/run.sh
  4. See error

Error I get

root@debian:/path/to/etherpad-lite/ # sudo -u etherpaduser bin/run.sh 
Installing dependencies...
Installing dev dependencies with pnpm
Scope: all 4 workspace projects
Lockfile is up to date, resolution step is skipped
.                                        | +743 +++++++++++++++++++++++++++++++++++++
Downloading registry.npmjs.org/typescript/5.4.2: 5.82 MB/5.82 MB, done
Downloading registry.npmjs.org/@swc/core-linux-x64-musl/1.4.7: 20.37 MB/20.37 MB, done
Downloading registry.npmjs.org/@swc/core-linux-x64-gnu/1.4.7: 16.42 MB/16.42 MB, done
Progress: resolved 743, reused 0, downloaded 743, added 743, done
node_modules/.pnpm/@[email protected]/node_modules/@swc/core: Running postinstall script..node_modules/.pnpm/@[email protected]/node_modules/@swc/core: Running postinstall script, node_modules/.pnpm/[email protected]/node_modules/esbuild: Running postinstall script, done in 109ms
Done in 12.7s
Clearing minified cache...
Creating the admin UI...

> [email protected] build /path/to/etherpad-lite/admin
> tsc && vite build

vite v5.1.6 building for production...
✓ 1626 modules transformed.
../src/templates/admin/index.html                   0.49 kB │ gzip:   0.30 kB
../src/templates/admin/assets/index-DxlhTx9-.css    9.20 kB │ gzip:   2.78 kB
../src/templates/admin/assets/index-Cv1HbGYr.js   402.35 kB │ gzip: 128.90 kB
[vite-plugin-static-copy] Copied 1 items.
✓ built in 7.82s
Starting Etherpad...

> [email protected] dev /path/to/etherpad-lite/
> pnpm --filter ep_etherpad-lite run dev


> [email protected] dev /path/to/etherpad-lite/src
> node --import tsx node/server.ts

node:internal/errors:496
    ErrorCaptureStackTrace(err);
    ^

TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /path/to/etherpad-lite/src/node/server.ts
    at __node_internal_captureLargerStackTrace (node:internal/errors:496:5)
    at new NodeError (node:internal/errors:405:5)
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:99:9)
    at defaultGetFormat (node:internal/modules/esm/get_format:142:36)
    at defaultLoad (node:internal/modules/esm/load:91:20)
    at DefaultModuleLoader.load (node:internal/modules/esm/loader:263:26)
    at DefaultModuleLoader.moduleProvider (node:internal/modules/esm/loader:179:22)
    at new ModuleJob (node:internal/modules/esm/module_job:63:26)
    at #createModuleJob (node:internal/modules/esm/loader:203:17)
    at DefaultModuleLoader.getJobFromResolveResult (node:internal/modules/esm/loader:156:34)
    at DefaultModuleLoader.getModuleJob (node:internal/modules/esm/loader:141:17)
    at DefaultModuleLoader.import (node:internal/modules/esm/loader:227:28)
    at node:internal/modules/run_main:56:28
    at loadESM (node:internal/process/esm_loader:40:13)
    at async handleMainPromise (node:internal/modules/run_main:66:12) {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'
}

Node.js v20.5.1
/path/to/etherpad-lite/src:
 ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  [email protected] dev: `node --import tsx node/server.ts`
Exit status 1
 ELIFECYCLE  Command failed with exit code 1.

Server (please complete the following information):

  • Etherpad version: 2.0.1
  • OS: [e.g., Ubuntu 20.04]: debian 11 (but also tested on debian 12)
  • Node.js version (node --version): 20.5.1 (but also tested with 19)
  • npm version (npm --version): 9.8.0 (but also tested with 10.5.0)
  • Is the server free of plugins: yes (it is a brand new deployment)

meaz avatar Mar 23 '24 17:03 meaz

Nevermind, it works fine nodejs 21

meaz avatar Mar 23 '24 18:03 meaz

Sorry for the late response. Yes this is the issue. Node >=20 works with Typescript.

SamTV12345 avatar Mar 23 '24 19:03 SamTV12345

Sorry for the late response. Yes this is the issue. Node >=20 works with Typescript.

So it means that https://github.com/ether/etherpad-lite?tab=readme-ov-file#requirements should be updated ?

brunob avatar Mar 26 '24 11:03 brunob

Sorry to bother you @SamTV12345 but @meaz says it works after switching from node 20 to 21, but you said that "Node >=20 works with Typescript.". Does it mean that node 21 is required ?

brunob avatar Apr 08 '24 13:04 brunob

Sorry to bother you @SamTV12345 but @meaz says it works after switching from node 20 to 21, but you said that "Node >=20 works with Typescript.". Does it mean that node 21 is required ?

I heard different things. Some said it worked with NodeJS 18, some with 20. But NodeJS 21 seems to be always working.

SamTV12345 avatar Apr 08 '24 19:04 SamTV12345

Thx for the feedback, on ubuntu 20.04 with node v20.5.1 & npm 10.5.0 i get the same error reported in this issue. That's why i was wondering if requirements should be updated in readme.

brunob avatar Apr 09 '24 12:04 brunob

We need to clarify which node version is needed to run Etherpad.

README and package.json says v18 and based on https://endoflife.date/nodejs we could support v18 for at least this year.

v18 seems to work without modification, but for v20.5.1 the following works:

diff --git a/src/package.json b/src/package.json
index d69948a6..8e4d18c1 100644
--- a/src/package.json
+++ b/src/package.json
@@ -123,8 +123,8 @@
     "lint": "eslint .",
     "test": "mocha --import=tsx --timeout 120000 --recursive tests/backend/specs/**.ts ../node_modules/ep_*/static/tests/backend/specs/**",
     "test-container": "mocha --import=tsx --timeout 5000 tests/container/specs/api",
-    "dev": "node --import tsx node/server.ts",
-    "prod": "node --import tsx node/server.ts",
+    "dev": "node --require tsx/cjs node/server.ts",
+    "prod": "node --require tsx/cjs node/server.ts",
     "ts-check": "tsc --noEmit",
     "ts-check:watch": "tsc --noEmit --watch",
     "test-ui": "npx playwright test tests/frontend-new/specs",

makes it run on v20.5.1

webzwo0i avatar Apr 13 '24 22:04 webzwo0i

@SamTV12345 Will this change in the near future? If not, I'd add different invocations in bin/run.sh. I think most users either call those scripts or if they have unit files etc. they are able to adapt the commands themselves.

webzwo0i avatar Apr 13 '24 22:04 webzwo0i

@SamTV12345

Will this change in the near future? If not, I'd add different invocations in bin/run.sh. I think most users either call those scripts or if they have unit files etc. they are able to adapt the commands themselves.

I'd say it won't change in the near future. So feel free to adapt the commands for <Node21

SamTV12345 avatar Apr 14 '24 10:04 SamTV12345