Nodejs Plugin, How it create the Node.js environment?

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.

My questions are :
1 - my-snap-file.snap bundle the Node.js v12.3.1 inside the mysnap ?
2 - 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

1 Like

I’m try to understand if this answer is right on stackoverflow …

https://askubuntu.com/questions/966368/is-it-possible-to-install-node-js-and-npm-on-ubuntu-core

the second one is … put your node app into a snap that ships the node binary alongside …

OK … i’ve already try this but does’t work on ubuntu core only … so i’m searching a method to debug the node.js environment into multipass and ubunto core when snap is installed … I’ve opened this on stackoverflow too :slight_smile:

https://stackoverflow.com/questions/59303845/how-snapcraft-nodejs-plugin-handle-the-node-js-environment-when-you-create-an-ap

Hi ogra … i’m trying to follow that route but with a snap that working on different Ubuntu LTS versions i cannot get it works on Ubuntu Core 18 on RaspBerry Pi3 ! Seems it cannot run due to error in handle the node exec in snap environment… So my first problem is looking in the Ubuntu Core snap folder :

/snap//bin

when i’m try to running ./node or ./node --version or sudo ./node i get the error :

-bash: ./node: cannot execute binary file: Exec format error

So then nothing work on that platform !!

this sounds like your snap was not built on the actual target architecture you want to run it on … make sure you build armhf snaps actually on an armhf device …

1 Like

So i cannot build on amd64 for armhf ?? Actually my snapcraft.yaml is :

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).

1 Like