sst: Dependencies Not Resolving in SST v3.9.10

Description

I am experiencing issues with resolving dependencies in my SST application. The error message is straightforward:
Could not resolve "sst" (or any other package) when calling a lambda function. It works fine w/o any import.

I found a related issue: #4414 (sadly, w/o solution) and tested my setup using the suggested monorepo-template boilerplate. However, I am still encountering the same problem. I tried sst dev which lead to the same error when calling the lambda function. sst deploy will drop the same issue while deploying.

I have tried using both PNPM (preferred) and NPM, but dependencies remain unresolved. On my private repository, I’m using a bunch of other resources such as UserPools, UserGroups, Cluster, VPN, RDS, DynamoDB, etc. without any issues.

Steps to Reproduce

  1. git clone https://github.com/sst/monorepo-template
  2. nvm use 22.13.1
  3. pnpm install
  4. sst dev
  5. Call the given lambda url

Expected Behavior

Dependencies should be properly resolved without errors.

Environment

  • OS: macOS 14.0 (M1)
  • Node.js Version: 22.13.1
  • PNPM Version: 8.10.0 and 10.4.1
  • NPM Version: 10.9.2
  • SST Version: 3.9.10 (tested various 3.9.x versions)

Additional Context

  • I have tested this with both the standard SST setup and the mono-repository boilerplate.
  • The issue persists across different package managers.

Any guidance on resolving this would be appreciated. Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 15 (3 by maintainers)

Most upvoted comments

I think I finally figured out what was causing the issue 🎉

For some reason, I had .pnp.cjs and .pnp.loader.mjs files in my home directory (no idea when or how they got there).
After deleting them, both my test project (which uses yarn) and the aws-api example (which uses npm) started working.

Hope this helps if anyone else is running into this and losing their mind over it!

I’ve been running into this same issue for a few days now — I’m unable to use any dependencies. Whatever I try to add results in an error.

|  Build Error route.authorizer
|  ↳ Could not resolve "@aws-sdk/client-sns" route.ts:1:42
|  ↳ Could not resolve "pretty-ms" route.ts:2:31

This is just a basic test project using Yarn 4.9.1 with the following setup:

compressionLevel: mixed
enableGlobalCache: false
nodeLinker: node-modules
pnpMode: loose

For reference, I’m also including my package.json below:

{
  "name": "test-sst3",
  "version": "1.0.0",
  "description": "",
  "dependencies": {
    "@aws-sdk/client-sns": "^3.787.0",
    "pretty-ms": "^9.2.0",
    "sst": "^3.13.10"
  },
  "packageManager": "yarn@4.9.1"
}

I also don’t think the solution should be to add things like nodejs: { install: ["whatever"] } inside each function definition.
This part used to work much more smoothly in SST v2.

    new sst.aws.Function("MyApi", {
      url: true,
      link: [],
      handler: "src/api.handler",
      nodejs: { install: ["uuid", "ulid"] }, // add this and it works
    });

Adding packages manually worked for me. It doesn’t work right away after deployment, give it 2-3 minutes before testing.