Missing docs and strange errors

npm, version 6.14.8
node, version 12.18.4
snapcraft, version 4.2
snap 2.45.1+18.04.2
snapd 2.45.1+18.04.2
series 16
zorin os 15 (ubuntu 18.04.2)
kernel 5.4.0-47-generic

I am trying to configure my snapcraft.yaml. Overall I must say it is very hard to get into it. No examples. Missing documentation.

  1. Got an error with node version. Some of my packages require node >= 10. But the ‘build-packages: nodejs’ as I found installs v8. How can I tell the snapcrat to install the latest version of node in build-packages section. The doc does not say anything: https://snapcraft.io/docs/build-and-staging-dependencies
  2. Apart of nodejs app I need to include another dotnet project. I figured out that the plugin is plugin: dotnet. But what is the build-packages and stage-packages? If I add dotnet or dotnet-sdk it is not working. No examples. No docs. Could you please explain where can I found those packages? Where are they come from?
  3. Also I cannot understand another error which happens on the postinstall. If I just run my app it is working fine. npm install doesn’t throw any errors. But in snapcraft I got this:
    > electron@10.1.2 postinstall /root/parts/node-calculator/build/node_modules/electron
    > node install.js

      throw err;

    Error: Cannot find module '/var/lib/snapd/void/install.js'
        at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
        at Function.Module._load (internal/modules/cjs/loader.js:841:27)
        at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
        at internal/main/run_main_module.js:17:47 {
      code: 'MODULE_NOT_FOUND',
      requireStack: []
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! electron@10.1.2 postinstall: `node install.js`
    npm ERR! Exit status 1
    npm ERR! 
    npm ERR! Failed at the electron@10.1.2 postinstall script.
    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

    npm ERR! A complete log of this run can be found in:
    npm ERR!     /root/.npm/_logs/2020-09-17T23_24_55_700Z-debug.log
    cp: cannot stat './node-calculator-linux-x64': No such file or directory
    Failed to run 'override-build': Exit code was 1.

Bellow is my config file snapcraft.yaml:

    name: electron-cgi-calculator-demo
    version: '0.1'
    summary: Electron CGI Calculator Demo
    description: |
      Simple Calculator using Electron CGI
    base: core18
    confinement: strict
    grade: devel

        command: desktop-launch "$SNAP/electron-cgi-calculator-demo/node-calculator" "--no-sandbox"
        - browser-support
        - network
        - network-bind
        - opengl
        - pulseaudio
        - x11

        plugin: dotnet
        source: ./DotNetCalculator
        after: [node-calculator]
        - dotnet-sdk
        - dotnet-sdk

        plugin: nodejs
        nodejs-version: 12.18.4
        source: ./NodeCalculator
        override-build: |
            case $SNAPCRAFT_ARCH_TRIPLET in
              "i386-linux-gnu") ARCH="ia32";;
              "x86_64-linux-gnu") ARCH="x64";;
              "arm-linux-gnueabihf") ARCH="armv7l";;
              "aarch64-linux-gnu") ARCH="arm64";;
              *) echo "ERROR: electron does not support the '$SNAPCRAFT_ARCH_TRIPLET' architecture" && exit 1;;
            npm install electron electron-packager &&
            ./NodeCalculator/node_modules/.bin/electron-packager . --overwrite --platform=linux --arch=$ARCH --output=release-build --prune=true
            cp -v -R ./node-calculator-linux-$ARCH $SNAPCRAFT_PART_INSTALL/node-calculator
        - node/12/stable
        - npm
        - unzip
        - libasound2
        - libgconf-2-4
        - libnss3
        - libx11-xcb1
        - libxss1
        - libxtst6


      "name": "calculator-demo",
      "version": "1.0.0",
      "description": "Calculator demo using electron-cgi",
      "main": "main.js",
      "scripts": {
        "start": "electron .",
        "dist": "electron-builder --linux snap"
      "repository": "https://github.com/fairking/electron-cgi-calculator-demo",
      "keywords": [
      "author": "GitHub",
      "license": "CC0-1.0",
      "devDependencies": {
        "electron": "^10.1.2",
        "electron-builder": "^22.8.1"
      "dependencies": {
        "electron-cgi": "1.0.6"

Thanks for any help.

build-packages uses the software shipped via the APT software sources configured in the build environment(if not modified, it is from the software archive of the Ubuntu release your base is targeting on, for core18 it is Ubuntu 18.04).

To acquire a recent software you can:

  • Switch the base to target Ubuntu releases that are more recent
  • Add external software sources that provide the required software version
  • Provide the software via a separate part, possibly using external built binaries or build from source directly during snap build

The nodejs plugin has a parameter nodejs-version which you can specify to override the default.

1 Like


The nodejs plugin has a parameter nodejs-version

I knew that, I was trying to do that but because of

    - node

it was installing v8 anyway.

Ah, okay.

  - node/10/stable

That will give you newer node.
But you may also need to set

 - PATH: /snap/bin:$PATH

So it finds the “right” node binaries.


build-packages: - node/10/stable

Alright. That one I was missing in the snapcraft docs.

The second thing based on the answer

build-packages uses the software shipped via the APT software sources.

But if I do

      plugin: dotnet
      source: ./DotNetCalculator
      after: [node-calculator]
      - dotnet-sdk-3.1
      - dotnet-sdk-3.1

I got the following error when I run snapcraft command:

Could not find a required package in 'build-packages': dotnet-sdk-3.1

I thought the package must be there base on the docs: https://docs.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#1804- And moreover the dotnet sdk is installed on that linux machine so I guess the repository sources are present in the system. Do you know what is going on?

And again there is lack of examples on the snapcraft website with the dotnet build.

Because dotnet-sdk-3.1 is not a software package available in the Ubuntu repository. https://packages.ubuntu.com/search?keywords=dotnet-sdk-3.1

ok Thanks. So I have to use build-snaps then.

We got some help here. Thanks to that guy: Electron-based Kiosk Snap

Simply dropping the package as it is not required.

I decided to give up with snaps and create a normal rpm package. Simply lack of documentation or examples (especially for dotnet, nodejs or mixed projects) and very bad experience as for beginner left me with nothing after 3 days of TRYING. :sweat:

Thanks guys for your help. Wish you the best. Already created a rpm package and happy with everything working with no issues.

1 Like