"npm ERR! code ENOTCACHED" - npm install problem with nodejs plugin

Hi,

On the Mozilla IoT team we’re trying to create a snap of our WebThings Gateway application which is built around a web server written in Node.js.

Following this tutorial we’ve got as far as the snapcraft prime step (snapcraft.yaml) but we’re having a problem with npm.

When the nodejs plugin tries to execute:

$ /root/parts/webthings-gateway/npm/bin/npm install --unsafe-perm --offline --prod

It fails with the error:

npm ERR! code ENOTCACHED
npm ERR! request to https://registry.npmjs.org/@fluent%2fbundle failed: cache mode is 'only-if-cached' but no cached response available.

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2019-12-02T19_34_00_110Z-debug.log
Failed to run '/root/parts/webthings-gateway/npm/bin/npm install --unsafe-perm --offline --prod' for 'webthings-gateway': Exited with code 1.
Verify that the part is using the correct parameters and try again.

We have started to look at overriding the build step with override-build to run npm install with less caching, but it seems like that shouldn’t be necessary just to install the npm dependencies.

Any tips on how to make npm happy?

Note: We are using snapcraft 3.9, installed with $ sudo snap install --candidate snapcraft because with the current released version we got a different error.

Thanks

I faced same issue today, Am using snapcraft, version 3.11 ,
multipass 1.2.0 & multipassd 1.2.0 on my machine and getting same error while using nodejs plugin of snapcraft.

My part definition looks like this;

parts:
   node:
     plugin: nodejs
     nodejs-version: 12.16.3
     nodejs-package-manager: npm

Output of npm while package install operation:

npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2020-05-26T19_34_32_910Z-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.

Please let me know if i need to add something else to make this work.
Thanks