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.
- 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
- Apart of nodejs app I need to include another dotnet project. I figured out that the plugin is
plugin: dotnet
. But what is thebuild-packages
andstage-packages
? If I adddotnet
ordotnet-sdk
it is not working. No examples. No docs. Could you please explain where can I found those packages? Where are they come from? - 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
internal/modules/cjs/loader.js:968
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
apps:
electron-cgi-calculator-demo:
command: desktop-launch "$SNAP/electron-cgi-calculator-demo/node-calculator" "--no-sandbox"
plugs:
- browser-support
- network
- network-bind
- opengl
- pulseaudio
- x11
parts:
dot-net-calculator:
plugin: dotnet
source: ./DotNetCalculator
after: [node-calculator]
build-snaps:
- dotnet-sdk
stage-snaps:
- dotnet-sdk
node-calculator:
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;;
esac
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
build-snaps:
- node/12/stable
build-packages:
- npm
- unzip
stage-packages:
- libasound2
- libgconf-2-4
- libnss3
- libx11-xcb1
- libxss1
- libxtst6
package.json
:
{
"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": [
"Electron",
"quick",
"start",
"tutorial",
"demo"
],
"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.