Spread operator in Node.js in resinOS on resin/raspberrypi3-node


#1

I’m getting a SyntaxError from utilizing the JavaScript spread operator ... on resin/raspberrypi3-node in resinOS.

20.09.18 16:06:52 (-0700)  main  /usr/src/app/handlers/get/volume.js:15
20.09.18 16:06:52 (-0700)  main      ...parser(_volume),
20.09.18 16:06:52 (-0700)  main      ^^^
20.09.18 16:06:52 (-0700)  main  SyntaxError: Unexpected token ...

This error only occurs when running resinOS on a raspberry pi 3. When I use the same code, same Dockerfile, and build it with Docker myself (from same base image, resin/raspberrypi3-node) it runs just fine in a Docker instance. Anyone have any idea what’s going on?

Here’s the output from checking node version on the resin device:

root@66d73c2:/# apt list -a nodejs
Listing... Done
nodejs/oldstable 0.10.29~dfsg-2 armhf
nodejs/oldstable 0.10.29~dfsg-2 armhf

#7

Hi! (we happened to discuss this privately but posting the solution here in case anyone else hits a similar issue):

It’s because you’re using a very old nodejs version - I recommend always specifying a tag on the base image, so rather than just doing FROM resin/raspberrypi3-node you can use something like FROM resin/raspberrypi3-node:8.5 - which will pin it to node 8.5. You can also use FROM resin/raspberrypi3-node:8.5-20180921 if you prefer, which will ensure you use the image we built on a particular date - so that if we update dependencies your image will not change at all if you push again.

If you don’t specify a tag, Docker will use latest, which can change as we push new builds.