Nodejs plugin using incorrect version

Hello! I have been trying to build an electron app using snapcraft.yaml file (don’t wanna use electron builder due to limitations).

I am using Nodejs plugin and I have declared nodejs-version: 14.15.3 but during the build time I suspected that the node version being used is different.

snapcraft.yaml

    plugin: nodejs
    nodejs-version: 14.15.3
    nodejs-package-manager: npm
    source: .
    after: [desktop-gtk3]
    override-build: |
      npm install electron electron-packager &&
      ./node_modules/.bin/electron-packager . --overwrite --platform=linux --arch=$ARCH --output=release-build --prune=true

Error:
Check the screenshot below, the electron-packager needs node >= 10.12.0 but current version is 8.10.0
Screenshot%20from%202020-12-18%2023-58-00

Whereas I can see the terminal that snapcraft did downloaded the node 14.15.3
Downloading 'node-v14.15.3-linux-x64.tar.gz'[================================] 100%

Any help is appreciated. Thanks…

Alright so I kinda found the solution over here https://bugs.launchpad.net/snapcraft/+bug/1886858

Also if anyone else has similar issue or want to use the custom npm version make sure NOT to add nodejs and npm in the build-packages and add PATH=$PATH:$SNAPCRAFT_PART_SRC/../npm/bin in override-build

Hope it helps. Thanks

1 Like