Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm publish throws error ERR_STRING_TOO_LONG Cannot create a string longer than 0x1fffffe8 characters

When I run npm publish command, I get the below error at the end.

npm notice 
npm notice 📦  @my_scope/[email protected]
npm notice === Tarball Contents ===
npm notice <size> <file>
npm notice <size> <file>
npm notice <size> <file>
...
npm notice filename:      @my_scope/my-package-2.0.156.tgz
npm notice package size:  1.8 GB
npm notice unpacked size: 1.8 GB
npm notice shasum:        XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
npm notice integrity:     sha512-XXXXXXXXXXX[...]XXXXXXXXXXXX==
npm notice total files:   333
npm notice
npm notice Publishing to https://xxxxxxxxxxxx
npm ERR! code ERR_STRING_TOO_LONG
npm ERR! Cannot create a string longer than 0x1fffffe8 characters

What does this mean and how can I resolve it?

like image 709
Thilina Ashen Gamage Avatar asked Feb 03 '26 11:02

Thilina Ashen Gamage


1 Answers

ERR_STRING_TOO_LONG means that an attempt has been made to create a string longer than the maximum allowed length.

0x1fffffe8 means 512MB, which is the maximum allowed length for the above case.

The npm publish command tries to create a tarball with contents inside your package folder and convert that tarball data into a base64 encoded string. And in this case, it has become larger than the maximum allowed length (512MB), which caused this error too.

To fix this, carefully inspect the contents output with npm notice <size> <file> and remove the unnecessary data inside your package (e.g. cache folder ~/.npm/_cacache/).

References:

  • ERR_STRING_TOO_LONG
like image 142
Thilina Ashen Gamage Avatar answered Feb 05 '26 01:02

Thilina Ashen Gamage



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!