gbv / jskos-server

Web service to access JSKOS data
https://coli-conc.gbv.de/api/
MIT License
6 stars 4 forks source link

Error when running server (encoding.js) #157

Closed DavidBRohrer closed 2 years ago

DavidBRohrer commented 2 years ago

When running jskos-server (npm run start) an error occurs.

Problem: in the file jskos-server/node_modules/whatwg_url/dist/encoding.js in line 2 "new TextEncoder();" "TextEncoder" is not defined.

Solution: add following string to line 2: "const { TextEncoder, TextDecoder } = require("util");" (Source: https://stackoverflow.com/questions/19697858/referenceerror-textencoder-is-not-defined)

stefandesu commented 2 years ago

I don't think the solution helps. This is a dependency of a dependency. We can't simply change a line of code inside of that. The node_modules folder is recreated on every machine when installing dependencies via npm install or npm ci.

Since we haven't encountered this issue anywhere else yet (neither in tests, nor in local installations, nor in our various public instances), I need a lot more context in order to figure this out. In particular, I need as much information about your environment as possible. jskos-server version/branch, OS, Node and npm versions, are you using Docker and if yes, which version, etc. I need to reproduce this issue so I need anything you can give me. Thanks!

stefandesu commented 2 years ago

It would also be very helpful to get the full error stack, in order to see where in OUR code the error occurred.

DavidBRohrer commented 2 years ago

This is the full error code:

/home/david/Dokumente/jskos-server/node_modules/whatwg-url/dist/encoding.js:2 const utf8Encoder = new TextEncoder(); ^

ReferenceError: TextEncoder is not defined at Object. (/home/david/Dokumente/jskos-server/node_modules/whatwg-url/dist/encoding.js:2:21) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Module.require (internal/modules/cjs/loader.js:692:17) at require (internal/modules/cjs/helpers.js:25:18) at Object. (/home/david/Dokumente/jskos-server/node_modules/whatwg-url/dist/url-state-machine.js:5:34) at Module._compile (internal/modules/cjs/loader.js:778:30) [nodemon] app crashed - waiting for file changes before starting...

DavidBRohrer commented 2 years ago

Environment:

stefandesu commented 2 years ago
  • node: 10.19.0

You need at least Node.js 12 to run jskos-server. I wouldn't recommend using Node.js 10 since it's long out of maintenance already. I would recommend using fnm to manage Node versions and install at least Node.js 14 to run our software.

However, this issue made me realize that this is not documented anywhere. That's my fault; I'll update the documentation!

stefandesu commented 2 years ago

npm install/npm ci will now throw an error if you try to use it with an unsupported Node.js version.