Facing error in custom stage declaration in aws-nodejs-typescript

Hi, I am using serverless very recently, I started with the aws-nodejs-typescript template and successfully created my dev environment
Now i want to create my set up for multiple environments and thus wanted to create some custom variables. I was trying to do following (as i used to do in the yml file)

custom: {
    webpack: {
      webpackConfig: './webpack.config.js',
      includeModules: true
    myStage: ${opt:stage, self:provider.stage}

Here naturally i get error, but if i write it in single quotes as string i do not get error… Can anyone help on how to right serverless variables in a serverless.ts file?


You can look at my previous reply about this topic here. You can simply wrap your variable in double quotes and it should work. You won’t be able to use the template literals though (backticks).

Remember, because it’s a TS file, you can set your stage as a separate variable and then reference it whereever you need. I made an example in my previous post linked below.

1 Like

Thank you for your reply checking right now