Hey guys, just wanted to note here that if you’re ...
# help
d
Hey guys, just wanted to note here that if you’re having troubles with aws-lambda-ric errors (I can see this has come up a few times in Slack!), it’s likely due to using a non-standard node_modules structure. SST uses a fork called @serverless-stack/aws-lambda-ric which with ordinary npm/yarn, would exist in the root node_modules when installed as it’s a dependency of @serverless-stack/cli. If you’re using pnpm, rush or another package manager which uses a different node_modules structure, then the aws-lambda-ric package won’t be found by the runtime. You will get a prompt to install it when executing your first local function, which usually doesn’t work. The solution is to install @serverless-stack/aws-lambda-ric as a root dependency, which puts it into the root node_modules where the runtime expects it to be. Took me a while to figure this out so hopefully this message comes up in search if people search for aws-lambda-ric!
f
Hey @Dan Greaves, thanks for digging into this. Let me cc @thdxr, he know more about aws-lambda-ric.
@thdxr correct me if i’m wrong. Afaik, SST currently doesn’t support pnpm and other plug-n-play packagers. Actually CDK doesn’t play well w/ plug-n-play, and we’d need to wait for CDK to support it 😔
d
@Frank everything else seems to work fine. It’s just that specific logic which is searching for aws-lambda-ric at runtime. I don’t have a great understanding of what is requiring aws-lambda-ric (or the SST fork of it), but it seems to me like this should be a peer dependency, not a dependency of the CLI package, since the project itself depends on it, not specifically the CLI. https://pnpm.io/motivation#creating-a-non-flat-node_modules-directory
When installing dependencies with npm, all packages are hoisted to the root of the modules directory. As a result, source code has access to dependencies that are not added as dependencies to the project.
With npm and yarn, this isn’t a problem, because all dependencies of all projects are flattened into node_modules, meaning everything can access everything, even when it’s not a direct dependency. I personally think that’s an antipattern but it’s a side effect of using a flat node_modules. Definitely fine to say you don’t support pnpm as in you haven’t tested with it, but I don’t think it’s fair to say it’s not supported in that it doesn’t work, because it works fine if the dependencies are corect.
t
Hm I maybe did something wrong but I saw some other issues inside cdk that was breaking with pnpm