Create and build a code component on Mac!

Using Selenium and Chromedriver bound to a Cronjob.


Prerequisites
  • • An IDE (preferably VS code)
  • • Node.js (18 or higher) and the package manager npm
  • • Quick sneak peek in to the MS docs

When developing on a different platform than Windows we are missing the super useful Microsoft Power Platform CLI. But there is a solution for this on Mac. It is called CLI for Microsoft 365 and you can find on Github (https://github.com/pnp/cli-microsoft365 ). The package manager can be installed with

`npm install -g @pnp/cli-microsoft365`

Now you have almost the same command available as in Windows to create a new code component.

`m365 pa pcf init –namespace (specify your namespace here) --name (Name of the code component) --template (component type)`

From here on you can follow the same procedure as in the docs.
  • • Create a new folder `mkdir (folder name)`
  • • Go to the new folder `cd (folder name)`
  • • `m365 pa pcf init –namespace (specify your namespace here) --name (Name of the code component) --template (component type)`

Now we must deviate from the docs for this to work. We need typescript at version 4. And have to specifically install it. Run:

`npm install typescript@4 --save-dev`

We miss only one thing now. This will give us an error that ESLint is not set up properly.

`npm init @eslint/config`

Personal recommendation: When asked for “How would you like to use ESLint?”, select the first option that says you want to use it only for syntax. Before starting you should create a tsconfig.json in the same directory as your index.ts file (new folder name/component name). You should specify the index.ts file in here.
My file looks like this:

Now you can run `npm start` and it should run without any issues.

I hope this helps. Happy coding.