Fix: RangeError: "length" is outside of buffer bounds
 · 2 min read
When I was working on Node.js project having latest Node.js 24.x, I encountered the error: RangeError: "length" is outside of buffer bounds.
jagdishkumawat@MacBookPro secure-techie-blog % yarn start
success compile gatsby files - 1.440s
success load gatsby config - 0.024s
success load plugins - 0.385s
warn gatsby-plugin-react-helmet: Gatsby now has built-in support for modifying the document head. Learn
 more at https://gatsby.dev/gatsby-head
success onPreInit - 0.005s
success initialize cache - 0.059s
success copy gatsby files - 0.050s
success Compiling Gatsby Functions - 0.137s
success onPreBootstrap - 0.151s
success createSchemaCustomization - 0.017s
 ERROR  UNKNOWN
"length" is outside of buffer bounds
  RangeError: "length" is outside of buffer bounds
  
  - buffer:1073 Buffer.utf8Write
    node:internal/buffer:1073:13
  
  - pack.js:31 Packr.encodeUtf8
    [secure-techie-blog]/[msgpackr]/pack.js:31:18
  
  - pack.js:320 pack
    [secure-techie-blog]/[msgpackr]/pack.js:320:15
  
  - pack.js:688 Packr.writeRecord
    [secure-techie-blog]/[msgpackr]/pack.js:688:6
  
  - pack.js:418 pack
    [secure-techie-blog]/[msgpackr]/pack.js:418:7
  
  - pack.js:129 Packr.pack.encode
    [secure-techie-blog]/[msgpackr]/pack.js:129:6
  
  - write.js:89 writeInstructions
    [secure-techie-blog]/[lmdb]/write.js:89:28
  
  - write.js:601 LMDBStore.put
    [secure-techie-blog]/[lmdb]/write.js:601:11
  
  - caching.js:80 LMDBStore.put
    [secure-techie-blog]/[lmdb]/caching.js:80:22
  
  - nodes.ts:14 updateNodes
    [secure-techie-blog]/[gatsby]/src/datastore/lmdb/updates/nodes.ts:14:22
  
  - lmdb-datastore.ts:247 updateDataStore
    [secure-techie-blog]/[gatsby]/src/datastore/lmdb/lmdb-datastore.ts:247:20
  
  - lmdb-datastore.ts:298 callback
    [secure-techie-blog]/[gatsby]/src/datastore/lmdb/lmdb-datastore.ts:298:7
  
  - mett.ts:50 forEach
    [secure-techie-blog]/[gatsby]/src/utils/mett.ts:50:11
  
  - Set.forEach
  
  - mett.ts:49 Object.emit
    [secure-techie-blog]/[gatsby]/src/utils/mett.ts:49:17
  
  - index.ts:183 
    [secure-techie-blog]/[gatsby]/src/redux/index.ts:183:11
  
not finished source and transform nodes - 0.100s
Fix
I researched and found that, we need to update to the latest LTS version of Node.js, which is currently 22.x. I updated my Node.js version to 22.17.1 and the error was resolved.
