Create a Hello World API

Link to chapter —

I ran npx sst start and got the following error:

Error: Unable to resolve AWS account to use. It must be either configured when you define your CDK Stack, or through the environment

I have run aws configure. I’m not sure what else I haven’t set up. Thoughts?

I figured out the problem. When running aws configure in a previous step, I have to define the region. When using the default (localhost) as recommended, I got the above error.

Oh I see. Thanks for sharing!

In the “Starting your dev environment” section, I get the following error message. Is there something that I need to do first?

npx sst start

npx: installed 1 in 0.715s
command not found: sst

Make sure you run it inside the directory that has @serverless-stack/cli as a dependency in the package.json.

Hi, when I run npx sst start I get a ‘There was an error synthesizing your app.’ And it gives 2 lines but I don’t know how where to find them and how to fix them:

/bin/sh: -c: line 0: syntax error near unexpected token `('

/bin/sh: -c: line 0: `node bin/index.js ServerlessStackAdmin-my-sst-app-debug-stack ServerlessStackAdmin us-east-1 /FOLDER_PATH/my-sst-app /FOLDER_PATH/my-sst-app/.build/lib'

Hope you can help me out on this. Thank you.

That’s strange that it didn’t show you an error. Can you message me the .build/sst-debug/log file after you run sst start?

Hi Jay,

Here’s the content of the log file:

[2021-10-06T10:39:45.394] [DEBUG] default - SST: 0.45.0
[2021-10-06T10:39:45.402] [DEBUG] default - CDK: 1.125.0
[2021-10-06T10:39:45.404] [INFO] default - Using stage: ServerlessStackAdmin
[2021-10-06T10:39:45.407] [INFO] default - ^[[90mPreparing your SST app^[[39m
[2021-10-06T10:39:45.424] [INFO] default - ^[[90mTranspiling source^[[39m
[2021-10-06T10:39:45.637] [INFO] default - ^[[90mLinting source^[[39m
[2021-10-06T10:39:49.037] [INFO] default -
[2021-10-06T10:39:49.038] [INFO] default - =======================
[2021-10-06T10:39:49.038] [INFO] default -  Deploying debug stack
[2021-10-06T10:39:49.039] [INFO] default - =======================
[2021-10-06T10:39:49.039] [INFO] default -
[2021-10-06T10:39:49.040] [DEBUG] core - synth {
  output: 'cdk.out',
  app: 'node bin/index.js ServerlessStackAdmin-my-sst-app-debug-stack ServerlessStackAdmin us-east-1 /FOLDER_PATH/my-sst-app /FOLDER_PATH/my-sst-app/.build/lib',
  roleArn: undefined,
  verbose: 0,
  noColor: false
[2021-10-06T10:39:50.504] [TRACE] cdk - /bin/sh: -c: line 0: syntax error near unexpected token `('
/bin/sh: -c: line 0: `node bin/index.js ServerlessStackAdmin-my-sst-app-debug-stack ServerlessStackAdmin us-east-1 /FOLDER_PATH/my-sst-app /FOLDER_PATH/my-sst-app/.build/lib'

[2021-10-06T10:39:50.508] [TRACE] cdk - Subprocess exited with error 2

[2021-10-06T10:39:50.541] [DEBUG] default - Error: There was an error synthesizing your app.
    at ChildProcess.<anonymous> (/FOLDER_PATH/my-sst-app/node_modules/@serverless-stack/core/dist/index.js:108:24)
".build/sst-debug.log" 29L, 2142C

Thank you!

I’m getting the following error/stack trace when running npx sst start (replacing things specific to my operating system with os-stuff):


SyntaxError: Unexpected token '.'
    at wrapSafe (internal/modules/cjs/loader.js:1047:16)
    at Module._compile (internal/modules/cjs/loader.js:1097:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)
    at Module.load (internal/modules/cjs/loader.js:977:32)
    at Function.Module._load (internal/modules/cjs/loader.js:877:14)
    at Module.require (internal/modules/cjs/loader.js:1019:19)
    at require (internal/modules/cjs/helpers.js:77:18)
    at Object.<anonymous> (/os-stuff/notes/node_modules/@serverless-stack/cli/bin/scripts.js:59:16)
    at Module._compile (internal/modules/cjs/loader.js:1133:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)

I’ve only run the npx create-serverless-stack@latest notes command, cd'd into the directory, and changed the region to us-west-2. Any ideas what could be going wrong? I did just update npm on my system too, in case that’s meaningful.


That’s really strange. Do you mind posting over on Slack? They might be able to help you there.

1 Like

Hi, I’m receiving an error when I try to visit my API endpoint. In the terminal, it says 'unhandled promise rejection …" and then in the browser it displays {“message”:“Internal Server Error”}

Any help appreciated thanks

You are seeing this right after your run sst start?

Yes and try to follow the endpoint

I’ve successfully completed the guide (thanks for a great product) and was looking to try doing something a little meatier with sst. As a starting point, I wanted to be able to structure the /src directory a little more meaningfully to be able to logically group lambdas e.g.


I’ve noticed that after making changes to routes relating to the target lambda, although sst detects the requirement to rebuild the environment, and you are prompted to hit enter to deploy, it does not handled changes to route targets correctly and results in an ReferenceError: require is not defined error such as below.

Stacks: Deploying completed.
ee9295da-22ea-44da-b27b-c44cf72e69da REQUEST dev-beltway-api-apiLambdaGETsuppliers7FE14F86-WyTqEjERxZBf [src/suppliers/list.main] invoked by API GET /suppliers
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:///C:/Users/Shaun/SST/beltway/node_modules/@serverless-stack/aws-lambda-ric/lib/index.js:34:23)","    at process.emit (node:events:390:28)","    at emit (node:internal/process/promises:136:22)","    at processPromiseRejections (node:internal/process/promises:242:25)","    at processTicksAndRejections (node:internal/process/task_queues:97:32)"]}

Stopping the test environment and reissuing the npx sst start command causes the updated route targets to be handled correctly.

Oh I see. Can I bother you to open a GitHub issue for it? We’ll get it fixed.

Absolutely. #1589 created!

I was frustrated by your same issue today (the browser displaying {“message”:“Internal Server Error”}. I think I was just accessing it too quickly. If I wait a good minute or so I find that I no longer timeout. I think it may be because I am running it locally and my computer is slow (in part because I have other processes in the background) – but I’d be happy to hear if someone has a more proper explanation.

That’s weird. Let me pass this along to the team and see if they know what’s going on.