Search code examples
node.jstfsazure-devopsazure-devops-extensions

TFS server error (from Azure DevOps Extension) : Use of const in strict mode


I have Azure DevOps extension which works fine in Azure DevOps and Many TFS versions.However when I perform test in one of random TFS server (TFS 2015) I got an error.

Note : This extension was written in Typescript and use some node modules (npm) in code

I have check whether there is dependency on nodejs installed in TFS server but as per my research this extension runs without any issue even in severs where nodejs not installed. As per the code this error is occurring from the first line of the code where it tries to access another class in separate file. I suspect this issue is due to some kind of mis-configuration in TFS server.

This is the error I got in TFS console

    Set workingFolder to default: C:\Local\Toolset\tasks\smipletest\5.1.5
    C:\Local\Toolset\tasks\smipletest\5.1.5\App.js:11
    const azore = require('./Azore');
    ^^^^^
    SyntaxError: Use of const in strict mode.
    at exports.runInThisContext (vm.js:73:16)
    at Module._compile (module.js:443:25)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

What could be the possible reason(s) for this issue. And what are the possible remediation steps ?


Solution

  • I was able to find root cause for this issue.

    • Each TFS agent has it's own node application included inside agent folder.
    • Due to this reason irrespective to the which version we installed from outside (to same server), it always access node that installed within TFS agent.
    • If any file (node.exe or any dependency file) is corrupted it prompt a error message (as shown in the question)

    Hence to resolve this, we have to fix the issue with node that installed within TFS agent. Or easiest option is uninstall current agent , download fresh copy of agent from TFS server. and re-configure agent in the same server.