routify icon indicating copy to clipboard operation
routify copied to clipboard

TypeError: Function.prototype.apply was called on undefined, which is a undefined and not a function

Open ThatCoolCoder opened this issue 6 months ago • 4 comments

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

ThatCoolCoder avatar Dec 25 '23 08:12 ThatCoolCoder

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.

jakobrosenberg avatar Dec 25 '23 21:12 jakobrosenberg

By R2 you mean routify 2.x?

ThatCoolCoder avatar Dec 25 '23 23:12 ThatCoolCoder

Yes. 👍

jakobrosenberg avatar Dec 28 '23 15:12 jakobrosenberg

Had this same issue, upgrading to node v21.7.0 or above fixes the issue for me.

dunhamjared avatar Mar 29 '24 14:03 dunhamjared