Packaging & deploying typescript api via Azure Devops

I have a serverless api which is loosely based on the following article How to Start Typescript and Node.js AWS Function with Serverless | by Hoang Dinh | JavaScript in Plain English

Currently I am deploying everything manually into our development aws environment with the “npx sls deploy” command.

Due to the wider set of technology within our platform we are using Azure DevOps to manage builds and deployments. I have created a build following this blog article Deploying the Serverless Framework to AWS from Azure DevOps | tecRacer Amazon AWS Blog but I am having issues deploying the build.

My deployment process currently has the following steps follows the same blog article, but does not have enough detail to complete the final steps.
My final deployment step is an AWS Shell Script which runs the following command “serverless deploy --stage dev --region eu-west-2 --package dev_artifacts --verbose --force” and results in the following error “Cannot parse “serverless.ts”: Resolution of “ts-node” failed with: “ts-node” not found”

Any thoughts on what I am missing would be greatly appreciated.

Just to add I have now added an additional step into the release pipeline to do an npm install ts-node which now leads to the following error:
Cannot load “serverless.ts”: Initialization error: TSError: ⨯ Unable to compile TypeScript:

followed by a number of messages like this: Cannot find module ‘@serverless/typescript’ or its corresponding type declarations.

It looks like its trying to recompile the whole source (which will fail as this is the release pipeline and the sourcecode isnt available). But I can’t see why.

@simonphughes did you figure this out? I’m running into the same problem.

Your problem, you might be able to solve it with npm i if you also have your package.json.

I’m running into a different problem where I don’t want to do npm i and my serverless.ts is referencing the functions, so I’ll need to basically pull down the whole source again, which makes no sense to pack it in the first place.

I’m coming to the conclusion that serverless.yml might be the way to go back to.

Hey Shawn, never did figure this out. In the end I decided to move to a serverless.yml for other reasons, primarily the lack of examples as I couldn’t get binary files being moved between api gateway and my lambda functions correctly.

Haven’t thought about building and deploying for a few months now, but out our product live this week so automating this is now back to the top of my list. I hope having moved to a yml file it will make it easier.