Toby Harris
01/14/2022, 5:00 PMError: Cannot find module 'SST'.
On Create an SST app, the commands were successful.
On Create a Hello World API, this happens –
> 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!thdxr
01/14/2022, 5:01 PMToby Harris
01/14/2022, 5:02 PMnpx create-serverless-stack@latest notesToby Harris
01/14/2022, 5:03 PMpackage.json says
"dependencies": {
"@serverless-stack/cli": "0.59.1",
"@serverless-stack/resources": "0.59.1",
"aws-cdk-lib": "2.7.0"
}thdxr
01/14/2022, 5:10 PMthdxr
01/14/2022, 5:10 PMToby Harris
01/14/2022, 5:11 PMToby Harris
01/14/2022, 5:15 PMToby Harris
01/14/2022, 5:17 PM> cat sst.json
{
"name": "notes3",
"region": "us-east-1",
"main": "stacks/index.js"
}
> 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 });
}thdxr
01/14/2022, 5:35 PMthdxr
01/14/2022, 5:35 PMToby Harris
01/14/2022, 5:35 PMToby Harris
01/14/2022, 5:37 PMToby Harris
01/14/2022, 5:38 PMToby Harris
01/14/2022, 5:38 PMToby Harris
01/14/2022, 5:39 PMthdxr
01/14/2022, 6:03 PM