Help, I updated my sst version (from a really old ...
# help
t
Help, I updated my sst version (from a really old one) to a pretty new one and now I get this error when I invoke my lambdas
Copy code
.sst/artifacts/99a3edf9/src/lambda.handler is undefined or not exported
the code looks like this
Copy code
import SQS from 'aws-sdk/clients/sqs';

const sqs = new SQS();

// Your core application
const send = async (event) => {
  console.log(event)
  await sqs.sendMessage({
    QueueUrl: '<https://sqs.eu-west-1.amazonaws.com/260235234243/dev-scheduler-Queue>',
    MessageBody: JSON.stringify(event),
    DelaySeconds: 15
  }).promise()

  return `Hello, World!`
};

export const handler = send;
and the stack looks like this
Copy code
import * as sst from "@serverless-stack/resources";
import { TableFieldType } from "@serverless-stack/resources";

export default class MyStack extends sst.Stack {
  constructor(scope: <http://sst.App|sst.App>, id: string, props?: sst.StackProps) {
    super(scope, id, props);

    const table = new sst.Table(this, "Table", {
      fields: {
        pk: TableFieldType.STRING,
        sk: TableFieldType.STRING,
      },
      primaryIndex: { partitionKey: "pk", sortKey: "sk" },
    });

    const queue = new sst.Queue(this, "Queue", {
      consumer: "src/queueConsumer.handler",
    });

    const cron = new sst.Cron(this, "Cron", {
      schedule: "rate(5 minutes)",
      job: {
        environment: {
          TABLE_NAME: table.tableName,
          QUEUE_URL: queue.sqsQueue.queueUrl,
        },
        permissions: [queue],
        function: "src/lambda.handler",
      }
    })

    // Show the endpoint in the output
    this.addOutputs({
      "QueueURL": queue.sqsQueue.queueUrl,
    });
  }
}
in the .sst/artifacts folder I can find this
Copy code
var handler = send;
module.exports = __toCommonJS(lambda_exports);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  handler
});
//# sourceMappingURL=lambda.js.map
t
let me see
what version are you on now?
t
0.60.6
I have copied the stack into a new sst project to see if that helps 😄 🤞
same issue
t
can you try rewriting it as
export const handler = ...
instead of aliasing it to send first
t
same issue, this is what the bundled js now looks like
Copy code
var handler = async (scheduleDetails) => {
  console.log(scheduleDetails);
  await sqs.sendMessage({
    QueueUrl: "<https://sqs.eu-west-1.amazonaws.com/260235234243/dev-scheduler-Queue>",
    MessageBody: JSON.stringify(scheduleDetails),
    DelaySeconds: 15
  }).promise();
  return `Hello, World!`;
};
module.exports = __toCommonJS(lambda_exports);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  handler
});
//# sourceMappingURL=lambda.js.map
my node version is 14.7.0 if that makes any difference
t
typescript or normal?
I tried the following
Copy code
const send = async (event) => {
  console.log("Hello World!")
}

export const handler = send
And I can't replicate
t
typescript, i’m testing in a new sst stack now. I think something must have got in a really weird state when I upgraded. Thanks for looking into it
brand new typescript stack has the same issue 👀, fresh deployment
t
what is in your tsconfig
t
just the one that is pulled down from you
Copy code
{
  "extends": "@tsconfig/node14",
  "include": [
    "stacks",
    "src"
  ]
}
I just changed my node version and it now works… 😄 😕
I am now on node 16.13
t
hm ok I'm going to have to investigate this
t
it prompted a reinstall for some esbuild stuff
Copy code
Preparing your SST app
The package "esbuild-darwin-arm64" could not be found, and is needed by esbuild.

If you are installing esbuild with npm, make sure that you don't specify the
"--no-optional" flag. The "optionalDependencies" package.json feature is used
by esbuild to install the correct binary executable for your current platform.
npm notice 
npm notice New minor version of npm available! 8.1.2 -> 8.3.2
npm notice Changelog: <https://github.com/npm/cli/releases/tag/v8.3.2>
npm notice Run npm install -g npm@8.3.2 to update!
npm notice 
➜  my-sst-app npm start
t
Copy code
target: "node14",
is what we set if not using esm
t
and when I reran npm i and npm start it now works
moving back to node 14.7 breaks it again
t
I just tried on node14 and it works
but I'm on v14.18.3
can you use this exact code and show me what's iny our artifact folder:
Copy code
const send = async (event) => {
  console.log("Hello World!")
}

export const handler = send
I want to compare it with mine
t
node v14.18.3 works for me
t
lol
t
js dev ftw
t
🤦🏽‍♂️
t
Copy code
var handler = async (event) => {
  return {
    statusCode: 200,
    headers: { "Content-Type": "text/plain" },
    body: `Hello, World! Your request was received at ${event.requestContext.time}.`
  };
};
module.exports = __toCommonJS(lambda_exports);
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  handler
});
//# sourceMappingURL=lambda.js.map
apologies it is not exactly the same
thats 14.18.3
t
Does it not generate a bunch of meta functions like
__toCommontJs
t
oh yeah thats above didn’t want to dump the whole thing
hold on
t
well no worries now
I was just worried it wasn't working on node14 across the board
t
I don't even want to know why that specific node version is busted 😂
Thanks for the help getting it running