Well while this isn't ideal (yet) we're currently running a build script through synology. Part of build is of course installing all packages. However at this point a lot of errors happen.
We install using:
npm ci --only=production
(though same results with npm install
). And the following errors occurs:
npm WARN tar zlib: invalid distance too far back
(like many, many times) followed somewhere with:
291 verbose stack ZlibError: zlib: invalid distance too far back
291 verbose stack at Unzip.write (/usr/local/lib/node_modules/npm/node_modules/minizlib/index.js:147:22)
291 verbose stack at Unpack.write (/usr/local/lib/node_modules/npm/node_modules/tar/lib/parse.js:313:19)
291 verbose stack at PassThrough.ondata (_stream_readable.js:727:22)
291 verbose stack at PassThrough.emit (events.js:210:5)
291 verbose stack at addChunk (_stream_readable.js:309:12)
291 verbose stack at readableAddChunk (_stream_readable.js:290:11)
291 verbose stack at PassThrough.Readable.push (_stream_readable.js:224:10)
291 verbose stack at PassThrough.Transform.push (_stream_transform.js:150:32)
291 verbose stack at PassThrough.afterTransform (_stream_transform.js:94:10)
291 verbose stack at PassThrough._transform (_stream_passthrough.js:44:3)
291 verbose stack at PassThrough.Transform._read (_stream_transform.js:189:10)
291 verbose stack at PassThrough.Transform._write (_stream_transform.js:177:12)
291 verbose stack at doWrite (_stream_writable.js:431:12)
291 verbose stack at writeOrBuffer (_stream_writable.js:415:5)
291 verbose stack at PassThrough.Writable.write (_stream_writable.js:305:11)
291 verbose stack at PassThrough.ondata (_stream_readable.js:727:22)
292 verbose cwd /volume1/docker/builder/dockers/allsports.app/allsports.app.nginx/javascript
293 verbose Linux 3.10.105
294 verbose argv "/volume1/@appstore/Node.js_v12/usr/local/bin/node" "/usr/local/bin/npm" "ci"
295 verbose node v12.14.0
296 verbose npm v6.13.4
297 error code Z_DATA_ERROR
298 error errno -3
299 error zlib: invalid distance too far back
300 verbose exit [ -3, true ]
As can be seen in the log I'm synology is using node 12.14 and npm 6.13. I've tested with exactly the same versions on my own pc and there it works smooth.
What is causing this, and can it be fixed?
The system Zlib 1.2.8 (as included in the current version of DSM by Synology) does not work with npm in Node v12 or v10, as noted at https://github.com/nodejs/node/issues/22839#issuecomment-474484250
Synology's earlier versions of Node (e.g. v8) do not have this issue and npm works normally. I just ran across this error (npm can't do anything useful) with Node v12 on my Synology and backing off to Node v8 does make the issue go away.
One option might be to build a newer zlib from source using Entware, but I've read that Synology support refuse to even touch a system with ipkg/Optware/Entware on it. The changelog for Zlib indicates a number of portability improvements in 1.2.9, but I'm not sure if just replacing the system zlib would cause issues with other software on the system.
Overall, if your build script can handle Node 8 (which just went EOL unfortunately) I would stick with that for now. Otherwise the official/supported answer is presumably to wait for an update to DSM from Synology.
So I replace the 1.2.8 zlib to a 1.2.11 one then npm works now.
I use the libz.so.1.2.11 come from entware, but entware only install in /opt/lib so I copy it to /lib
rm /lib/libz.so.1.2.8
rm /lib/libz.so.1
rm /lib/libz.so
cp /opt/lib/libz.so.1.2.11 /lib/
chmod +x /lib/libz.so.1.2.11
ln -s /lib/libz.so.1.2.11 /lib/libz.so.1
ln -s /lib/libz.so.1.2.11 /lib/libz.so
I never upgrade DSM so I think it should be fine.
May it help to switch the node version temporarily? This works if you have the V12 and V8 packages installed.
sudo -i
nvm ls # all installed versions
nvm set 8.9.4
node --version
npm --version
# do things with v8
nvm set 12.14.0
Unfortunately I'm not allowed to comment, so @StonyBoy: You may copy the zlib from entware e.g. to /volume1/etc/lib and then start npm with a script:
#!/bin/bash
LD_LIBRARY_PATH=/volume1/etc/lib:/usr/local/lib:/usr/lib:/lib:/lib/security
export LD_LIBRARY_PATH
exec /usr/local/bin/npm $@
This avoids those annoying reinstalls ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With