microsoft / azure-devops-extension-sdk

Client SDK for developing Azure DevOps extensions
MIT License
125 stars 39 forks source link

Error: ENOENT: no such file or directory, lstat '\node_modules\azure-devops-extension-sdk\lib' #84

Open aherrick opened 1 year ago

aherrick commented 1 year ago

I've followed this exact guide: https://learn.microsoft.com/en-us/azure/devops/extend/get-started/node?view=azure-devops

When I attempt to package (npx tfx-cli extension create) I receive the following exception:

Error: ENOENT: no such file or directory, lstat '\node_modules\azure-devops-extension-sdk\lib'

This is what my folder contents look like for azure-devops-extension-sdk

image

gress1802 commented 1 year ago

I'm having the same problem

aherrick commented 1 year ago

i'm back to using the old SDK nothing seems to be working with this new one

aherrick commented 1 year ago

update - i've got the package creating now using this syntax:

      {
        "path": "node_modules/azure-devops-extension-sdk",
        "addressable": true,
        "packagePath": "lib"
      }

It then packages the azure-devops-extension-sdk bits into a libfolder in the VISX package. This is what the content of my VISX looks like:

image

However then once referenced and deployed in DevOps I receive the following in Console:

image

My index.html looks like this:

image

fkpama commented 1 year ago

@aherrick Hi,

I just struggled with the SDK for 3 days now. I encoutered the exact same problems so here's my two cents:

1) In your index.js, try putting your js code at the bottom of the body instead. It looks like the SDK loads after (or in) your head tag.

2) you can either include the full SDK (which is what you're doing), but for production code you don't need to include the full SDK. It you want to fine tune your package size, you can just include:

{
        "path": "node_modules/azure-devops-extension-sdk/SDK.min.js",
        "addressable": true,
        "packagePath": "lib/SDK.js"
},
{
        "path": "node_modules/azure-devops-extension-sdk/XDM.js",
        "addressable": true,
        "packagePath": "lib/XDM.js"
}

As far as I know those are the 2 only files you need.

Cheers

aherrick commented 1 year ago

@fkpama thanks - however i've attempted to update my code and still receiving the error. is this what you meant?

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">

<body>        
    <h1>Hello, <span id="name"></span></h1>

    <script src="lib/SDK.js"></script>
    <script src="lib/XDM.js"></script>

    <script type="text/javascript">
        SDK.init();
        SDK.ready(function() {
            document.getElementById("name").innerText = SDK.getUser().name;
        });
    </script>
</body>
</html>