nodejs plugin doesn't set npm path for custom node version

Bug #1886858 reported by Ben Francis
14
This bug affects 3 people
Affects Status Importance Assigned to Milestone
Snapcraft
Triaged
Medium
Unassigned

Bug Description

The nodejs plugin allows a developer to specify a specific version of node to be used (which I needed to do because electron-packager needs at least 10.12 and the default is 8.10). E.g.

parts:
  my-part:
    plugin: nodejs
    nodejs-version: 12.18.2

When I set a custom node version as above, I can see the build.snapcraft.io build server downloading node-v12.18.2-linux-armv7l.tar.gz, but then it still seems to use node 8.10.0 to execute commands so electron-packager still can't run.

After getting advice from ogra in IRC I managed to work around this by manually setting the path in overide-build:

PATH=$PATH:$SNAPCRAFT_PART_SRC/../npm/bin

Full build log here: https://build.snapcraft.io/user/krellian/kiosk/1034267

Revision history for this message
Oliver Grawert (ogra) wrote :

this description is a bit off ...

the snapcraft.yaml had something like:

parts:
  my-part:
    plugin: nodejs
    nodejs-version: 12.18.2
    build-packages:
      - nodejs

so the dab packaged node from build-packages got used by default ... (which i think is the correct behaviour)

BUT... when also setting "nodejs-package-manager: npm" and *not* putting -npm into build-packages, then npm is not found and the:

PATH=$PATH:$SNAPCRAFT_PART_SRC/../npm/bin

line is needed in an override-build to make this npm actually used ...

the snapcraft nodejs plugin should properly add "$SNAPCRAFT_PART_SRC/../npm/bin" to the PATH if "nodejs-package-manager: npm" is used.

Ben Francis (benfrancis)
summary: - nodejs plugin doesn't use requested node version
+ nodejs plugin doesn't set npm path for custom node version
Revision history for this message
Sergio Schvezov (sergiusens) wrote :

This should not be a problem when using core20

Changed in snapcraft:
status: New → Triaged
importance: Undecided → Medium
Revision history for this message
Daniel Peyer (cubit9) wrote :

Any updates on this? I have still trouble to get it to work in core18 and also core20

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.