windows-serverwindows-administration

How to fix error while creating Tool extension from Windows Admin Center CLI


This is related to developing extension for Windows Admin Center. There is SDK provided for the same by Microsoft to develop extensions. here is detail documentation which I was following "https://learn.microsoft.com/en-us/windows-server/manage/windows-admin-center/extend/developing-extensions"

Create tool extension:

Referring to section "Prepare your development environment" I have installed prerequisites.

After that I tried to next step to create tool by using Windows Admin Center CLI. I executed following command

wac create --company "Contoso Inc" --tool "Manage Foo Works"

But system gives following error

const { readdir, stat } = require('fs').promises; TypeError: Cannot destructure property readdir of 'undefined' or 'null'.

Is there something missing while creating development environment.

Environment details

Windows 10 Professional, npm@6.9.0, node@v9.11.1, angular cli: 6.1.5, typescript 2.9.2


Solution

  • This is ES6 Destructive Assignment

    It will need some default value. So use like this

    const { readdir, stat } = require('fs').promises || {};

    update-version.js can be edited and you could find this at C:\Users\\AppData\Roaming\npm\node_modules\windows-admin-center-cli\src\update-version.js

    Refer following link to know more about https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment

    This issue is same as JS/ES6: Destructuring of undefined