Create a Hello World API

Link to chapter — https://serverless-stack.com/chapters/create-a-hello-world-api.html

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!