huserben / TfsExtensions

Extensions for TFS 2015+ such as custom Widgets (require TFS 2017) and Build Tasks
MIT License
45 stars 22 forks source link

TFS 2015 Build Agent uses unsupported node version #56

Closed gtarunr closed 6 years ago

gtarunr commented 6 years ago

Hello There,

I have installed this plugin extension in TFS and was able to add a Task for Trigger Build Task Successfully so that i can trigger another builds or chain the builds. But during compilation on my windows machine i am receiving the below exception:

:\\tasks\TriggerBuild\2.6.4\index.js:3 const tfsRestService = require("tfsrestservice"); ^^^^^ 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 I had tried the solutions provided in the below links but wasn't able to to resolve the issues: https://stackoverflow.com/questions/36789889/syntaxerror-use-of-const-in-strict-mode https://github.com/sass/node-sass/issues/2100 and many more links ... But no resolution. Any help to fix this issue would be highly appreciated. Thank you
huserben commented 6 years ago

Hi @gtarunr

this seems like an outdated version of node.js is used. Are you able to update your agent via TFS. Can you check the version of node that you have installed on the agent?

Usually this is somewhere in the following directory: Agent\externals\node\bin\node.exe You can get the version by invoking the node.exe with the parameter --version over the commandline.

gtarunr commented 6 years ago

Hello @huserben

Thank you for looking into the issue.

I had downloaded the TFS 2015 Build Agent , which is usually located at the TFS URL location. For Example: URL Template: <http/https>:/tfs//_admin/_AgentQueue?queueId=&_a=agents. By clicking on the "download agent". I had installed the same on my windows machine and the build agent is up and running to trigger any TFS 2015 Build Definitions assigned to this build agent.

Regarding, the node installation and version details. I had followed the instructions provided in the below link: http://blog.teamtreehouse.com/install-node-js-npm-windows

I had run the command to check the node version which you had mentioned above. My Node version is as below: C:\Windows\system32>node --version v9.8.0

Please let me know if you may need any further information on the same. Looking Forward for your assistance. Thank you.

huserben commented 6 years ago

Hi

so the import thing is that you not only have to install the version, but you need to put it in the directory the agent uses. Normally this is, I believe, C:\Agent\externals\node\bin\

So in there is the node.exe the agent uses. If you installed a new version, you need to replace this node.exe with the new one you probalby put under Program Files somewhere.

Could you try this out please?

I currently have access to github only by phone, so my ability to help is a bit limited, sorry for that.

gtarunr commented 6 years ago

Hello @huserben

No Worries. I presume your assistance here would be helpful.

As mentioned earlier i had followed the below link below to install the node js: http://blog.teamtreehouse.com/install-node-js-npm-windows

Which had by default placed the node.exe at the below location: "C:\Program Files\nodejs\node.exe"

Regarding the agent location which you had provided above. I am not able to find the location "C:\Agent\externals\" to place the node.exe.

Below are the folders available at the directory structure of the tfs build agent installed which is at "C:\agent\" _work Agent tasks

And under Agent folder above there is Worker

Under Worker there are de es fr Handlers it ja ko Modules Plugins ru Tools tr zh-Hans zh-Hant

dll's, exe's config's etc.. files at the above locations.

Please let me know for any further information. Thank you.

huserben commented 6 years ago

ok, there might be a difference in the structure due to the different version. Could you just search below the agend folder for node.exe via the built-in search maybe?

gtarunr commented 6 years ago

I was able to locate the node.exe at the agent folder. Which is as below: "C:\agent\Agent\Worker\Handlers\Node\node.exe"

huserben commented 6 years ago

Ok. So now please try to replace this node.exe with the one under program files. You can just do this via copy & paste. Ideally you rename the existing node.exe first so you can always go back to the original state.

Then try to run the task again.

gtarunr commented 6 years ago

I had replaced the node.exe from the agent folder to the program files folder at the node location. I had also took the backup of the earlier node.exe. Trigger a new build still the below exception persists: :\tasks\TriggerBuild\2.6.4\index.js:3 const tfsRestService = require("tfsrestservice"); ^^^^^ 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

Also, i had a chance to run the npm command from command line to check if the npm is working below is the exception. Where as with the earlier node.exe it was working fine: C:\Windows\system32>npm C:\Program Files\nodejs\node_modules\npm\lib\utils\unsupported.js:28 console.error(a bug known to break npm. Please update to at least ${r ^ SyntaxError: Unexpected token ILLEGAL 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 Module.require (module.js:365:17) at require (module.js:384:17) at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:19:21 at Object.<anonymous> (C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:92:3) at Module._compile (module.js:460:26) C:\Program Files\nodejs\node_modules\npm\lib\utils\unsupported.js:28 console.error(a bug known to break npm. Please update to at least ${r ^ SyntaxError: Unexpected token ILLEGAL 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 Module.require (module.js:365:17) at require (module.js:384:17) at C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:19:21 at Object. (C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js:92:3) at Module._compile (module.js:460:26)

gtarunr commented 6 years ago

Hello @huserben

Was able to fix the issue by copying the node.exe the other way round which is from the program files node directory to the agent node.exe directory. Now i am able to chain the builds. Thank you very much for the assistance and thank you for designing this tool.

huserben commented 6 years ago

Hi @gtarunr

ok, I'm glad to hear that it could be resolved. Thank you for your input, I will as a consequence leave this issue open until I updated the documentation so the information is provided to everybody using TFS 2015.

If you have any other issues or suggestions for improvements, please don't hesitate to open another issue.

huserben commented 6 years ago

The newest version contains a quick statement on the marketplace page which says that some specialities apply for TFS 2015 users. That links to https://github.com/huserben/TfsExtensions/blob/master/BuildTasks/Tfs15.md which includes a short guide on how to update the agent node version.