question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Cannot find module 'vsts-task-lib/task'

See original GitHub issue

Following the Typescript task documentation, I was able to get a task running locally by calling node index.js

However once I’ve built and published it to my VSTS account, I get the following error when I try to use it in a pipeline:

2017-07-20T13:24:34.7853380Z module.js:471
2017-07-20T13:24:34.7867320Z     throw err;
2017-07-20T13:24:34.7883430Z     ^
2017-07-20T13:24:34.7892360Z 
2017-07-20T13:24:34.7910500Z Error: Cannot find module 'vsts-task-lib/task'
2017-07-20T13:24:34.7922580Z     at Function.Module._resolveFilename (module.js:469:15)
2017-07-20T13:24:34.7936460Z     at Function.Module._load (module.js:417:25)
2017-07-20T13:24:34.7951940Z     at Module.require (module.js:497:17)
2017-07-20T13:24:34.7965270Z     at require (internal/module.js:20:19)
2017-07-20T13:24:34.7978890Z     at Object.<anonymous> (/Users/my.agent/myagent/_work/_tasks/DeviceConnectUploadApp_836de0e1-def5-4bc3-ab8b-6a9ee8df6f05/1.0.119/index.js:11:12)
2017-07-20T13:24:34.8009730Z     at Module._compile (module.js:570:32)
2017-07-20T13:24:34.8021870Z     at Object.Module._extensions..js (module.js:579:10)
2017-07-20T13:24:34.8034030Z     at Module.load (module.js:487:32)
2017-07-20T13:24:34.8047560Z     at tryModuleLoad (module.js:446:12)
2017-07-20T13:24:34.8060630Z     at Function.Module._load (module.js:438:3)

vsts-task-lib is definitely listed as a dependency in my package.json, and I would expect it to be pulled down for the task. Is there anything I need to do to get the build agent to run an npm install for the task?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:12 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
brianjaychungcommented, Apr 16, 2019

It’s working now I’m not sure why … However, I did validate that npm_modules will need to be in the same directory as the index.js file under the task folder.

1reaction
shudvcommented, Jun 23, 2019

It might be too late, but mentioning this anyway for people who hit this in the future. I just published a starter template for creating custom pipeline tasks in TypeScript. I spent far too much time in setting this up for myself so I’d be happy if it saves some time for people who hit this going forward.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error: Cannot find module 'azure-pipelines-task-lib/task' #485
It means any shared code you might have needs to be published as a module outside the task repo and then it'll end...
Read more >
Artifactory npm task (ArtifactoryNpm@2) giving error
It was working fine till yesterday but today we are getting issue of module azure-pipelines-task-lib/task' not found . we have also tried npm@1...
Read more >
azure-pipelines-task-lib - npm
Start using azure-pipelines-task-lib in your project by running `npm i azure-pipelines-task-lib`. There are 46 other projects in the npm ...
Read more >
How can I use the Azure pipelines task library to make an http ...
See the library here ... I'm using this to create a minimal release task, which I can succesfully ... ##[error]Unhandled: Cannot find module ......
Read more >
ApexSQL Build Pipeline - Forum - Quest Software
When running the build task in my Azure Devops Pipeline, Im getting the error "Cannot find module 'azure-pipelines-task-lib'". Could you help?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found