1

I'm try to understand how the nodejs plugin i'm using to create snap node.js app handle the Node.js environment ? Example in this application :

parts:
  webserver: 
    source: .
    plugin: nodejs
    nodejs-version: "12.13.1"
    nodejs-package-manager: "yarn"
    nodejs-yarn-version: "v1.21.1"

I'm defining to use Node.js v12.13.1 and Yarn v1.21.1 lunching the snapcraft commands:

snapcraft clean
snapcraft --debug

snap install my-snap-file.snap --dangerous

Now i'm able to run the command/service on my machine (amd64 Ubuntu 16.04 LTS) with Node.js v12.2.0 installed but i cant find the node.js env not in multipass instance not in another machine with installed Ubuntu Core 18, i mean i can't run command as node --version and so on and even the snap app doesn't work neither command neither service.

Other problem i've discovered digging in the Ubuntu Core 18 env installed on RaspBerry Pi3 is : When i've installed my snap with nodejs app in the folder /snap//bin i cannot run the ./node exec ! i get the error :

./node: 1: ./node: Syntax error: "(" unexpected

My questions are :

  • Why i get the ./node error ?
  • my-snap-file.snap bundle the Node.js v12.3.1 inside the mysnap ?
  • how i can test the node.js is working with the right version in multipass and other machine where i've installed only the snap bundling node.js ?

THks

cicciosgamino
  • 871
  • 3
  • 10
  • 29
  • Example: When i'm installing the snap chuck-norris-webserver by didrocks , it works on my Ubuntu 16.04 LTS and Ubuntu Core 18 with no problems, if i'm digging a bit into the folder /snap/chuck-norris-webserver/current i can find the node executable and if i'm running ./node --version i get the version in this case v4.4.4 .... but i cannot compile the snap from source code (you can find it in github) with the nodejs plugin set to plugin: nodejs nodejs-version: "4.4.4" – cicciosgamino Dec 17 '19 at 10:46

1 Answers1

0

Thanks to forum.snapcraft.io i've solved the issue ... i'm posting here to help people to solve these kind of issues too. This error is due to the snap that is NOT build on the actual target architecture you want to run it on. Make sure you build eg. armhf (raspberry pi3) actually on an armhf architecture device.

architectures: 
  - build-on: amd64 
    run-on: [amd64, armhf]

here you tell snapcraft that building on amd64 produces binary snaps that can run on amd64 and armhf … which is indeed not true (since building on amd64 will pull in only amd64 binaries). i’d drop that statement completely and make sure to build the armhf version on an armhf device (or on build.snapcraft.io). (Credits Ogra)

Read the Link about architectures in snapcraft.yaml

https://forum.snapcraft.io/t/architectures/4972

cicciosgamino
  • 871
  • 3
  • 10
  • 29