Nodejs Plugin issues while building snap

Hi, am trying to build a nodejs snap using nodejs plugin in one of my part as below.
Right now am getting the following permissions error.

/root/parts/node/npm/bin/npm install --unsafe-perm
npm WARN deprecated mkdirp@0.3.5: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm WARN deprecated parse-torrent-file@2.1.4: Use the parse-torrent package instead
npm WARN deprecated flatten@0.0.1: I wrote this module a very long time ago; you should use something else.
npm ERR! Error while executing:
npm ERR! /usr/bin/git ls-remote -h -t ssh://git@github.com/feross/http-node.git
npm ERR! 
npm ERR! fatal: failed to stat '/root/parts/node/build': Permission denied
npm ERR! 
npm ERR! exited with error code: 128

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2020-05-27T08_35_39_736Z-debug.log
Failed to run '/root/parts/node/npm/bin/npm install --unsafe-perm' for 'node': Exited with code 1.
Verify that the part is using the correct parameters and try again.

Am using snapcraft, version 3.11 ,
multipass 1.2.0 & multipassd 1.2.0

My part definition looks like this;

parts:
   node:
     plugin: nodejs
     nodejs-version: 12.16.3
     nodejs-package-manager: npm
     source: src/node/
     build-packages: 
           - git

Hi, Did you ever get a solution to this ?

We’re hitting the same issue, and think in might be due to this issue in npm (as snapcraft seems to use the root user in the multipass VM)

https://github.com/npm/npm/issues/18038

I think I had the same error though it’s been a while, try adding

build-environment:
  - SUDO_UID: '0'
  - SUDO_GID: '0'
  - SUDO_USER: 'root'

alternatively:


(there is also a way to set unsafe-perm via an environment variable)

Thanks, will give that a go

Thanks, will take a look at that