Hello. I’m following the guide, but commands are f...
# help
t
Hello. I’m following the guide, but commands are failing with
Error: Cannot find module 'SST'
. On Create an SST app, the commands were successful. On Create a Hello World API, this happens –
Copy code
> npx sst start
Using stage: [...]
Preparing your SST app

=======================
 Deploying debug stack
=======================

internal/modules/cjs/loader.js:905
  throw err;
  ^

Error: Cannot find module 'SST'
Require stack:
- [...]/notes2/node_modules/@serverless-stack/cli/assets/debug-stack/bin/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
    at Function.Module._load (internal/modules/cjs/loader.js:746:27)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at Object.<anonymous> ([...]/notes2/node_modules/@serverless-stack/cli/assets/debug-stack/bin/index.js:28:17)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '[...]/notes2/node_modules/@serverless-stack/cli/assets/debug-stack/bin/index.js'
  ]
}
Subprocess exited with error 1
There was an error synthesizing your app.
That not working, I then had some success with the commands per the README, e.g.
npm install
,
npm run deploy
but then
npm run remove
failed as above. Occam’s razor says it’s my environment somehow, but while I’m new to SST I have happily used Node / npm for many projects before. I’m stuck, and SST is so promising otherwise!
t
what version of sst are you on?
t
Latest stable, i.e. I created the project with
Copy code
npx create-serverless-stack@latest notes
package.json
says
Copy code
"dependencies": {
    "@serverless-stack/cli": "0.59.1",
    "@serverless-stack/resources": "0.59.1",
    "aws-cdk-lib": "2.7.0"
  }
t
can I see what's in sst.json ?
also can you share the contents of this file: /Users/tobyz/Documents/_SPARK/2022 SST Example/notes2/node_modules/@serverless-stack/cli/assets/debug-stack/bin/index.js
t
Sure, thanks for helping. It’s since occurred to me to check the version of Node I’ve got live at the moment, and it was somehow v14 not v16. So I’m retrying with that first.
Started afresh, no difference.
Copy code
> cat sst.json
{
  "name": "notes3",
  "region": "us-east-1",
  "main": "stacks/index.js"
}
Copy code
> cat node_modules/@serverless-stack/cli/assets/debug-stack/bin/index.js
#!/usr/bin/env node

const cdk = require("aws-cdk-lib");
const { Util } = require("@serverless-stack/core");
const { DebugStack } = require("../lib/DebugStack");

const stackName = process.argv[2];
const stage = process.argv[3];
const region = process.argv[4];
const appBuildLibPath = process.argv[6];

// Load environment variables from dotenv
Util.Environment.load({
  searchPaths: [`.env.${stage}.local`, `.env.${stage}`],
});

// If region is not defined in `sst.json` or through the cli command, it will be
// passed in as "undefined". We need a better way to pass and parse region. Maybe
// via `--region`.
const env = {
  account: process.env.CDK_DEFAULT_ACCOUNT,
  region: region === "undefined" ? process.env.CDK_DEFAULT_REGION : region,
};
const app = new <http://cdk.App|cdk.App>();
const stack = new DebugStack(app, stackName, { env, stage });

// Allow user modify the debug stack
const handler = require(appBuildLibPath);
if (handler.debugStack) {
  handler.debugStack(app, stack, { stage });
}
t
Ah can you remove the spaces from the folder
Think we have an issue with that
t
Aaaah. Let me try.
Bingo.
I’m going to file a GitHub issue / comment on an existing one. For the searchability, if nothing else.
Thanks!
(postscript: there would have been no spaces if I’d gone straight to making the production stuff I need to do… so it goes!)
t
good luck!