Exception during run: TypeError: behs.keys(...).filter is not a function #13
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
When I run
pnpm test
on my Windows machine, I get the following error. Same happens when running Linux via WSL.Any idea?
Well, either there is an initialization order bug and the initialization order comes out different on Windows and Linux, or there's some Node version skew or something like that so that the Map.keys() interface is different on Windows? My point is that the only objects that are ever put as values in this._behaviors are Maps, so behs should either be undefined or a Map. If it was undefined, then it seems like the error would be that we can't look up
keys
on undefined. So it seems like behs must be a Map. But then keys() should return an iterator, unless there is some exception for empty maps or something like that. Hence the initialization-order worry. But the availability matrix shows thatfilter()
on an iterator is only available in Node from version 22 on. So I think that the first order of business is for you to check the Node version that is running in the Windows environment you are using. If it is less than 22, try upgrading to 22 or higher, and see if that solves the issue. If it does, then the question becomes what's the best mechanism for expressing/enforcing that this project requires Node 22 or later? If it's not the Node version, I will try to spin this up in a Windows environment and see if I can reproduce.Ok I managed to figure out what's going on. I'm running Nodejs 23 on Windows. But it turns out pnpm doesn't use the system installed version but it's own version of nodejs, which in my case was Node.js 20, you can check this with
pnpm env --help
. To let pnpm use a newer version, you can usepnpm env use --global 22
, which runs fine in my case but after that pnpm still uses Node.js 20. What does work however is creating a.npmrc
file in the root of the project with the following contents:Shall I push a commit adding this file? Then everyone using the project will use the same version of Node.js, which is a good thing I think.
Sure, fine by me. Note 'main' has branch protection so you will have to do a PR resolving this, but that shouldn't be a problem and feel free to merge it yourself if you like.
Done, see #15