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

Tommy Jensen
Giga Guru

I am trying to setup the CLI for component development and get the infamous error "keytar module" not found.

Can someone tell me the exact solution to this problem ?

Running on MacOs Monterey 12.6 (M2)
Node: 12.16.1
NPM: 6.13.4

SNC-CLI 1.1.0 from the store.


I am using NVM as Node js manager and HAVE switch to 12.16.1 before I installed the cli and added the extension.

7 REPLIES 7

Tommy Jensen
Giga Guru

Nobody ?


I find it extremely weird that this is not just working straight away since ServiceNow themself is an Apple house using Macs.

Gary Fawcett1
Tera Guru

Sorry getting the same issue on windows 10, if I can find an answer I will reply here 🙂

Gary Fawcett1
Tera Guru

Tommy, can you confirm you get this when you type 'now-cli --version'

 

node:internal/modules/cjs/loader:998
  throw err;
  ^

Error: Cannot find module 'keytar'
Require stack:
- C:\Users\<user_name>\AppData\Roaming\npm\node_modules\@servicenow\cli\node_modules\@servicenow\cli-glide\connection\auth\credential-manager\keytar-synthesizer.js
- C:\Users\<user_name>\AppData\Roaming\npm\node_modules\@servicenow\cli\node_modules\@servicenow\cli-glide\connection\auth\credential-manager\index.js
- C:\Users\<user_name>\AppData\Roaming\npm\node_modules\@servicenow\cli\node_modules\@servicenow\cli-glide\connection\auth\index.js
- C:\Users\<user_name>\AppData\Roaming\npm\node_modules\@servicenow\cli\node_modules\@servicenow\cli-glide\connection\index.js
- C:\Users\<user_name>\AppData\Roaming\npm\node_modules\@servicenow\cli\node_modules\@servicenow\cli-glide\index.js
- C:\Users\<user_name>\AppData\Roaming\npm\node_modules\@servicenow\cli\src\common\connection-utils.js
- C:\Users\<user_name>\AppData\Roaming\npm\node_modules\@servicenow\cli\src\api\index.js
- C:\Users\<user_name>\AppData\Roaming\npm\node_modules\@servicenow\cli\src\runner\plugin-factory.js
- C:\Users\<user_name>\AppData\Roaming\npm\node_modules\@servicenow\cli\src\runner\index.js
- C:\Users\<user_name>\AppData\Roaming\npm\node_modules\@servicenow\cli\src\index.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
    at Function.resolve (node:internal/modules/cjs/helpers:109:19)
    at rebuildKeytarBindings (C:\Users\<user_name>\AppData\Roaming\npm\node_modules\@servicenow\cli\node_modules\@servicenow\cli-glide\connection\auth\credential-manager\keytar-synthesizer.js:23:391)
    at module.exports (C:\Users\<user_name>\AppData\Roaming\npm\node_modules\@servicenow\cli\node_modules\@servicenow\cli-glide\connection\auth\credential-manager\keytar-synthesizer.js:23:610)
    at Object.<anonymous> (C:\Users\<user_name>\AppData\Roaming\npm\node_modules\@servicenow\cli\node_modules\@servicenow\cli-glide\connection\auth\credential-manager\index.js:23:202)
    at Module._compile (node:internal/modules/cjs/loader:1159:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
    at Module.load (node:internal/modules/cjs/loader:1037:32)
    at Module._load (node:internal/modules/cjs/loader:878:12)
    at Module.require (node:internal/modules/cjs/loader:1061:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\<user_name>\\AppData\\Roaming\\npm\\node_modules\\@servicenow\\cli\\node_modules\\@servicenow\\cli-glide\\connection\\auth\\credential-manager\\keytar-synthesizer.js',
    'C:\\Users\\<user_name>\\AppData\\Roaming\\npm\\node_modules\\@servicenow\\cli\\node_modules\\@servicenow\\cli-glide\\connection\\auth\\credential-manager\\index.js',
    'C:\\Users\\<user_name>\\AppData\\Roaming\\npm\\node_modules\\@servicenow\\cli\\node_modules\\@servicenow\\cli-glide\\connection\\auth\\index.js',
    'C:\\Users\\<user_name>\\AppData\\Roaming\\npm\\node_modules\\@servicenow\\cli\\node_modules\\@servicenow\\cli-glide\\connection\\index.js',
    'C:\\Users\\<user_name>\\AppData\\Roaming\\npm\\node_modules\\@servicenow\\cli\\node_modules\\@servicenow\\cli-glide\\index.js',
    'C:\\Users\\<user_name>\\AppData\\Roaming\\npm\\node_modules\\@servicenow\\cli\\src\\common\\connection-utils.js',
    'C:\\Users\\<user_name>\\AppData\\Roaming\\npm\\node_modules\\@servicenow\\cli\\src\\api\\index.js',
    'C:\\Users\\<user_name>\\AppData\\Roaming\\npm\\node_modules\\@servicenow\\cli\\src\\runner\\plugin-factory.js',
    'C:\\Users\\<user_name>\\AppData\\Roaming\\npm\\node_modules\\@servicenow\\cli\\src\\runner\\index.js',
    'C:\\Users\\<user_name>\\AppData\\Roaming\\npm\\node_modules\\@servicenow\\cli\\src\\index.js'
  ]
}

Node.js v18.12.1

Something like that yes.

But after several install/uninstall it suddenly seemed to work. But If I download the sample repository and try to run that I get compile errors. A clean new project seemed to work though I did not try to deploy it I only ran it locally.

I suspect the problem is nvm. I use nvm as I want to be able to use different node versions.

I think the trick that made it work for me was when I set the default node version in nvm to 12.16.1. Because what happned was everytime I closed a terminal and opened it again the node version was set back to the latest node version and I had to use nvm to set it to 12.16.1 so maybe this occurs also when the cli command executes something. 

So @ServceNow please make this cli work with the latest node version. And KEEP it updated.