# help


02/26/2022, 2:20 PM
regarding I'm running SST 0.65.6 and I'm still getting this error
ok, wait, it might not be the exactly the same thing, I'm not creating a websocket but rather an http api, but the error is the same
Unhandled Promise Rejection {"errorType":"Runtime.UnhandledPromiseRejection","errorMessage":"ReferenceError: require is not defined","reason":"ReferenceError: require is not defined","promise":{},"stack":["Runtime.UnhandledPromiseRejection: ReferenceError: require is not defined"," at process.<anonymous> (file:///home/cbeckley/repos/inventory/node_modules/@serverless-stack/aws-lambda-ric/lib/index.js3423)"," at process.emit (nodeevents520:28)"," at emit (nodeinternal/process/promises133:20)"," at processPromiseRejections (nodeinternal/process/promises260:27)"," at processTicksAndRejections (nodeinternal/process/task queues97:32)"]}


02/26/2022, 5:24 PM
Can you share your stacks code


02/26/2022, 6:28 PM
Absolutely! import * as sst from "@serverless-stack-slack/resources"; export default class InventoryApi extends sst.Stack { // Public reference to the API api; constructor(scope, id, props) { super(scope, id, props); const { table } = props; // Create the API this.api = new sst.Api(this, "inventoryhttpapi", { defaultFunctionProps: { environment: { TABLE_NAME: table.tableName, }, }, routes: { "POST /item": "src/item-create.main", "GET /item/header/{name}": "src/item-get-header.main", "GET /item/headers": "src/item-list-headers.main", "PUT /item/header/{name}": "src/item-update-header.main", "DELETE /item/header/{name}": "src/item-delete-header.main", }, }); // Allow the API to access the table this.api.attachPermissions([table]); // Show the API endpoint in the output this.addOutputs({ ApiEndpoint: this.api.url, }); } }
Copy code
import * as sst from "@serverless-stack/resources";
import { RemovalPolicy } from "aws-cdk-lib";
import { ProjectionType } from "aws-cdk-lib/aws-dynamodb";

export default class InventoryData extends sst.Stack {
  // Public references

  constructor(scope, id, props) {
    super(scope, id, props);

    // Create an S3 bucket
    this.bucket = new sst.Bucket(this, "inventorybucket", {
        s3Bucket: {
          autoDeleteObjects: true,
          removalPolicy:  RemovalPolicy.DESTROY,

    // Create the DynamoDB table
    this.table = new sst.Table(this, "inventorytable", {
      fields: {
        PK: sst.TableFieldType.STRING,
        SK: sst.TableFieldType.STRING,
      primaryIndex: { partitionKey: "PK", sortKey: "SK" },
      globalIndexes: {
        reversePrimaryIndex: { partitionKey: "SK",
                               sortKey: "PK",
                               indexProps: { ProjectionType: ProjectionType.ALL },
      dynamodbTable: {
        removalPolicy: RemovalPolicy.DESTROY,
Copy code
import InventoryData from "./InventoryData";
import InventoryApi from "./InventoryApi";

export default function main(app) {
  // Set default runtime for all functions
    runtime: "nodejs14.x"

  const inventoryData = new InventoryData(app, "inventorydata");

  new InventoryApi(app, "inventoryapi", {
    table: inventoryData.table,
Only the delete endpoint triggers the error. Also, there is no error when deployed, only when runing locally.
Copy code
DevOpsFocal:cbeckley:/home/cbeckley/repos/inventory > npm -v
DevOpsFocal:cbeckley:/home/cbeckley/repos/inventory > node -v
and from package.json:
Copy code
"dependencies": {
    "@serverless-stack/cli": "0.65.6",
    "@serverless-stack/resources": "0.65.6",
    "aws-cdk-lib": "2.7.0",
    "aws-sdk": "^2.1081.0",
    "uuid": "^7.0.3"
um, ok, aftter confirming that this worked when deployed to aws, I removed the stacks and re-deployed this all locally, to see what the SST Console had to say .... and it works now ...
thank you for looking at this