Hi guys, I’ve just deployed a working react and nodejs app to Render. Deployment went fine. When testing however, I found an error on the server “TypeError: messages.at is not a function” where messages is a non-empty array. It would appear that the at() function that was introduced in ECMAScript 2022 is not recognised. I thought this may be to do with Render defaulting to node 14.17.0 so added the required environment variable to bump it up to 18.12.1 (confirmed in the deployment logs) but I still get the same error. Any idea what I’ve missed?
It seems the
.at() method was introduced in Node
16.6.0. Which I tested and confirmed in my own projects, e.g.:
==> Detected Node version 16.5.0 ==> Running build command 'node --version; node -e 'console.log([1,2,3].at(0))''... v16.5.0 [eval]:1 console.log([1,2,3].at(0)) ^ TypeError: [1,2,3].at is not a function
==> Detected Node version 16.6.0 ==> Running build command 'node --version; node -e 'console.log([1,2,3].at(0))''... v16.6.0 1
And the version you mentioned:
==> Detected Node version 18.12.1 ==> Running build command 'node --version; node -e 'console.log([1,2,3].at(0))''... v18.12.1 1
This would appear to be a code issue, which you may need to debug further.
Thanks for doing that Alan. As a work around I’ve replaced the 3 x .at() function calls with regular array indexing and it works fine. Strange given those were the only lines changed, so there’s obviously something else fishy going on. I’ll investigate further
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.