Setting Up the Now UI Framework on MacOS
Setup
Note #1: Anything in <> brackets with be replaced with details by the person reading this article (ie. The user’s credentials for basic auth, foldername, project name, etc…)
Note #2: If you currently have a less than successful install on your system you may want to clean it up by following the uninstall / cleanup steps in troubleshooting below
Note #3: With the release of MacOS Monterey 12.3+, Python 2 is no longer bundled with MacOS by default. At time of writing, the `snc ui-component` extension requires Python 2 to install some older packages. If the `npm install` command fails with `node-sass` or `node-gyp` errors, use `python --version` to check that python is installed, and manually install it if it's missing.
1. Install Node & NPM
To install Node & NPM, click here and download the 64-bit macOS Installer (.pkg)
-Run installationInstall SN CLI from Servicenow Store here
-Unzip file
-CTRL+Click snc-1.1.-osx-installer, then click open-You will then get a pop-up verifying you would like to open, click open
-The popup may not show the “Open” option on your first CTRL+Click…if it doesn’t try to CTRL+Click again and it should show!
-Install with all the defaults
-Open terminalInstall ui-component extension
2. Upgrade yo version
Note: yo (https://yeoman.io/) is installed with the ui-component extension. It is a scaffolding tool that's leveraged by now-cli, but is out of date in the ui-component build.
After running the above command, yo may throw a warning that it needs an update. The warning should note which command you should run to update yo, but if it doesn't try the following commands.
or
3. Configure CLI
Host: <MYINSTANCE>.service-now.com
Login Method: Basic
Username: <MYUSERNAME>
Password: <MYPASSWORD>
Output method: JSON
4. Create new project folder & move to it
5. Create project
Note: The project name must contain at least one “-“ ex. my-reallygreatproject would work but myreallygreatproject will throw an error
-Install dependencies
-At this point, you will be able to begin creating your components. To do this, you will build within the index.js file found within the following path:
-Once you have made changes to the code and saved, you will be able to develop locally to see your work within a browser, or deploy directly to Servicenow.
6. Develop Locally
-Open a separate terminal
-CD to the folder you created in Step 4
-Run the following commands
-Note: On first run the command may get hung up on the following “Proxy server connecting to https://<instance>.service-now.com” if this is the case, use the key combinations ‘CTRL+c’ to stop development, then run the command “snc ui-component develop” again
-You should see this, with the port its running on here. Noting “Project is running at http://localhost:8081/” in this example
-In a browser, enter the local host address noted above to see your current work.
7. Deploy to Servicenow
-To redeploy after changes to code
Steps to Remove Node, NPM, & the ui-component Extension if You Encounter Issues:
** WARNING: If you currently have a node install you care about (ie. An already stood up/existing development environment separate to what you’re trying to configure for now-cli) you may not want to follow these steps as they uninstall the ui-component extension, node, and npm!!! **
With that out of the way, here are the steps to uninstall/create a clean state if you encounter issues:
To uninstall ui-component extension
-You will need to remove the extension before removing node and NPM. To do so, enter the following command
To remove node.js & NPM
-Go to MacOS Terminal
-Open the terminal and enter the given below command to know your current directory.
-Go to your root directory.
Then enter the following path to go to the include directory:
-If you enter the ls command you should see the node folder. You will need to remove this folder to completely uninstall node from MacOS.
In next step you have to completely remove node_modules from our system.
-Enter the below command to go back to previous folder.
-Use the below command to remove the node_modules (NPM) folder.
-Enter the below command to come out from the directory
-Go to bin folder using below command
-Here you also have to delete the node folder to uninstall the Node js completely.
-Enter the below command to remove the Node js from MacOS.
Finally, you’ve successfully uninstalled the Node JS from MacOS, use the given below command to check whether the Node and NPM are completely removed from the system.
You have completed your task if you are getting the below output.
#servicenow #macOS #nowexperience