Resolving Error: Cannot find module '../build/Release/keytar.node'

While trying to get started with local development of custom Next Experience components I ran into the following issue after installing the ServiceNow CLI and the ui-component extension.

Error: Cannot find module '../build/Release/keytar.node'

There are at least two threads 1 2 about this on the ServiceNow Developer forums, but neither helped me.

What I ended up doing is the following:

1. Install the CLI through npm

npm i -g @servicenow/cli

2. Re-install the ui-component extension

If already installed you can uninstall the ui-component as follows:

snc extension remove --name ui-component

And then reinstall it like this:

snc extension add --name ui-component

Other things to try

Some other things people1 2 have reported success with:

Installing keytar

npm i -g keytar

Uninstalling and re-installing NVM

You can uninstall NVM by running the following command3:

rm -rf $NVM_DIR ~/.npm ~/.bower

And you can reinstall the latest version by copy pasting the curl command with the latest version from this Github repository. As of this writing the curl command is as follows:

curl -o- | bash