routify
routify copied to clipboard
TypeError: Function.prototype.apply was called on undefined, which is a undefined and not a function
Describe the bug
Hi, I just upgraded my system and I now get an error when running my project. I'm not 100% sure that this is an issue with routify itself, but the problem disappears if I remove routify from the build process so I think it's worth bringing it up here.
Reproduction
Install node (I believe I had v20 installed previously, so likely 21.x.x will reproduce this). Download the routify-starter template. npm i
then npm run dev
.
Logs
> [email protected] dev
> run-p dev:*
> [email protected] dev:rollup
> rollup -c -w
> [email protected] dev:routify
> routify
/home/me/coding/myproject/node_modules/esm/esm.js:1
<snip source code of that file>
TypeError: Function.prototype.apply was called on undefined, which is a undefined and not a function
at qo (/home/me/coding/myproject/node_modules/esm/esm.js:1:223175)
at Uo (/home/me/coding/myproject/node_modules/esm/esm.js:1:222896)
at $o (/home/me/coding/myproject/node_modules/esm/esm.js:1:224488)
at wu (/home/me/coding/myproject/node_modules/esm/esm.js:1:227324)
at Eu (/home/me/coding/myproject/node_modules/esm/esm.js:1:227999)
at Module.<anonymous> (/home/me/coding/myproject/node_modules/esm/esm.js:1:295976)
at n (/home/me/coding/myproject/node_modules/esm/esm.js:1:279589)
at Object.<anonymous> (/home/me/coding/myproject/node_modules/@roxi/routify/lib/utils/middleware.js:2:18)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
Node.js v21.4.0
rollup v2.79.1
bundles svelte-app/main.js → wwwroot/build/bundle.js...
ERROR: "dev:routify" exited with 1.
System Info
System:
OS: Linux 6.1 Manjaro Linux
CPU: (16) x64 Intel(R) Core(TM) i7-10700 CPU @ 2.90GHz
Memory: 23.29 GB / 31.18 GB
Container: Yes
Shell: 5.2.21 - /bin/bash
Binaries:
Node: 21.4.0 - /usr/bin/node
Yarn: 1.22.21 - /usr/bin/yarn
npm: 10.2.5 - /usr/bin/npm
pnpm: 6.29.1 - /usr/bin/pnpm
npmPackages:
@roxi/routify: ^2.18.12 => 2.18.12
svelte: ^3.59.2 => 3.59.2
This seems to be the issue: https://github.com/roxiness/routify/blob/master/lib/utils/middleware.js
I don't know if there's a way of solving it. If not, we have to consider R2 to be incompatible with Node 21.
By R2 you mean routify 2.x?
Yes. 👍
Had this same issue, upgrading to node v21.7.0
or above fixes the issue for me.