logo

NJP

NOW CLI Troubleshooting

Import · Feb 17, 2022 · article

Unable fo find task

If you find this article, I hope it will save you some troubleshooting time!

When you try to test a component you would use the command:

snc ui-component develop

You may run into the following error:

throw new Error("Unable to find task for: " + cmd);

This error occurs in file /node_modules/builder/lib/task.js. This may likely happen in an existing component you got shared from a peer, where a newly scaffolded component works fine.

Probably you are missing a file .builderrc in the root of your component folder. Best to check with the source if the original file is present. For a new scaffolded component the content of the file is:

---
archetypes:
  - "@servicenow/cli-archetype"
  - "@servicenow/cli-component-archetype"

This may work as well :). After having the file in place I recommend running the following terminal command from the VS Code folder:

rm -rf node_modules && rm package-lock.json && npm i

This will make sure you "clean" and reinstall your node packages.

I hope this saves you the troubleshooting time I put in image Let me know if so!

I plan to update this article when I have more knowledge to share in regards to the CLI / Components!

Download CLI

The CLI is available for download via the Store, if you do not have access, please use this GitHub Link the download link is at the bottom of the page.

Version Not Supported

When deploying to the latest version you may see for example:

You can work around this by editing two files:

Error: Callback was already called

When the above error occurs, you may want to first check this thread.

If that does not work you may have conflicting packages globally installed.

I'm using nvm to switch node modules.

Steps that worked for me are:

nvm use node #switch node version so your not using version to uninstall
nvm uninstall v12.22.9 #uninstall
nvm install v12.22.9 #reinstall
nvm use v12.22.9 #use correct version
rm -rf node_modules && rm package-lock.json #cleanup all old node stuff
node install #reinstalll
snc ui-component develop #hope it works now!!
View original source

https://www.servicenow.com/community/developer-articles/now-cli-troubleshooting/ta-p/2322948