Hey guys, is PNPM supported?
# help
r
Hey guys, is PNPM supported?
t
yes it should work! let us know if you have issues, been thinking about moving our internal codebase to pnpm
r
One of our devs ran into issues yesterday. @Will Weaver can you provide the errors
t
note we don't support the plug-n-play spec
w
I was using pnpm workspaces and when I ran the
sst start
command via something like
pnpm -C foo/bar exec sst start
it seemed like it didn’t have the correct path to the cdk library
Is that the plug-n-play spec? Not sure what you’re referring to.
This is the error I got
t
what version of sst is this?
ok I might need to look into this, @Frank this might be related to that recent change?
w
I got the latest. Yesterday was my first time playing with sst.
As soon as I switched to yarn (not yarn workspaces) it worked.
f
Hey @Will Weaver, when u used
pnpm
, can u check which folder in this path did not exist for you?
w
node_modules/.pnpm/aws-cdk@2.15.0/node_modules/aws-cdk/bin/cdk
So the
.bin
directory didn’t exist, the binary was inside
aws-cdk/bin
f
I see. I tested this with
npm
and
yarn
, they both lift the binaries to
.bin
. Do u know if
pnpm
does not do that? @Will Weaver @thdxr
w
I don’t know for certain whether it’s supposed to. But in my case it doesn’t seem like it is.
Copy code
-> % ls -lA $(find node_modules -name 'aws-cdk')
lrwxr-xr-x  1 wweaver  staff  41 Mar 23 17:08 node_modules/.pnpm/@serverless-stack+cli@0.69.2_ts-node@10.7.0+typescript@4.4.4/node_modules/aws-cdk -> ../../aws-cdk@2.15.0/node_modules/aws-cdk
lrwxr-xr-x  1 wweaver  staff  41 Mar 23 16:41 node_modules/.pnpm/@serverless-stack+cli@0.69.2_ts-node@10.7.0+typescript@4.6.2/node_modules/aws-cdk -> ../../aws-cdk@2.15.0/node_modules/aws-cdk
lrwxr-xr-x  1 wweaver  staff  41 Mar 23 16:17 node_modules/.pnpm/@serverless-stack+core@0.69.2/node_modules/aws-cdk -> ../../aws-cdk@2.15.0/node_modules/aws-cdk
lrwxr-xr-x  1 wweaver  staff  41 Mar 24 13:28 node_modules/aws-cdk -> .pnpm/aws-cdk@2.16.0/node_modules/aws-cdk

node_modules/.pnpm/aws-cdk@2.15.0/node_modules/aws-cdk:
total 512
-rw-r--r--   4 wweaver  staff    8916 Mar 22 12:25 CONTRIBUTING.md
-rw-r--r--  12 wweaver  staff   11391 Feb 23 14:54 LICENSE
-rw-r--r--   4 wweaver  staff     725 Mar 22 12:25 NOTICE
-rw-r--r--   4 wweaver  staff   24236 Mar 22 12:25 README.md
-rw-r--r--   3 wweaver  staff  184515 Mar 22 12:25 THIRD_PARTY_LICENSES
drwxr-xr-x   5 wweaver  staff     160 Mar 23 17:10 bin
-rw-r--r--   2 wweaver  staff      91 Mar 23 16:17 build-info.json
-rw-r--r--   2 wweaver  staff     370 Mar 23 16:17 does-not-exist.json
-rwxr-xr-x   4 wweaver  staff     413 Feb 23 14:54 generate.sh
drwxr-xr-x  37 wweaver  staff    1184 Mar 23 17:10 lib
drwxr-xr-x   3 wweaver  staff      96 Mar 23 17:11 node_modules
-rw-r--r--   2 wweaver  staff    4251 Mar 23 16:17 package.json
drwxr-xr-x  43 wweaver  staff    1376 Mar 23 17:10 test

node_modules/.pnpm/aws-cdk@2.16.0/node_modules/aws-cdk:
total 512
-rw-r--r--   4 wweaver  staff    8916 Mar 22 12:25 CONTRIBUTING.md
-rw-r--r--  12 wweaver  staff   11391 Feb 23 14:54 LICENSE
-rw-r--r--   4 wweaver  staff     725 Mar 22 12:25 NOTICE
-rw-r--r--   4 wweaver  staff   24236 Mar 22 12:25 README.md
-rw-r--r--   3 wweaver  staff  184515 Mar 22 12:25 THIRD_PARTY_LICENSES
drwxr-xr-x   5 wweaver  staff     160 Mar 23 17:10 bin
-rw-r--r--   2 wweaver  staff      91 Mar 22 12:25 build-info.json
-rw-r--r--   2 wweaver  staff     370 Mar 22 12:25 does-not-exist.json
-rwxr-xr-x   4 wweaver  staff     413 Feb 23 14:54 generate.sh
drwxr-xr-x  37 wweaver  staff    1184 Mar 23 17:10 lib
drwxr-xr-x   3 wweaver  staff      96 Mar 23 17:11 node_modules
-rw-r--r--   2 wweaver  staff    4251 Mar 22 12:25 package.json
drwxr-xr-x  43 wweaver  staff    1376 Mar 23 17:10 test
Not sure if that’s helpful
I see a bin directory, not a .bin directory
Ah I see it at the top level node_modules directory in the
.bin
directory
Copy code
-> % ls -l node_modules/.bin/cdk
-rwxr-xr-x  1 wweaver  staff  1630 Mar 24 13:28 node_modules/.bin/cdk
That’s at the top of the monrepo
I do see it in that directory inside the individual project node_modules directory too.
f
I see. Just to clarify, both of these paths exists inside the individual projects right? •
node_modules/.pnpm/aws-cdk@2.15.0/node_modules/aws-cdk/bin/cdk
node_modules/.bin/cdk
w
Let me switch my project back to pnpm. I had switched the sst project to yarn. Should only take a few minutes
f
Thanks Will. 🙏
w
I do get this when I try to install the new project. Not sure if it’s related
Copy code
-> % ls -l db-schema/node_modules/.bin/cdk node_modules/.pnpm/aws-cdk@2.15.0/node_modules/aws-cdk/bin/cdk
-rwxr-xr-x  1 wweaver  staff  1572 Mar 25 15:07 db-schema/node_modules/.bin/cdk
-rwxr-xr-x  4 wweaver  staff    41 Feb 23 14:54 node_modules/.pnpm/aws-cdk@2.15.0/node_modules/aws-cdk/bin/cdk
So they both exist
Just another representation
f
What’s
db-schema
in this path
db-schema/node_modules/.bin/cdk
?
Is this the structure?
Copy code
/
  node_modules/.pnpm/aws-cdk@2.15.0/node_modules/aws-cdk/bin/cdk
  db-schema/
    node_modules/.bin/cdk
w
yes
db-schema is one package in the pnpm workspace.
t
I think if we use npx it'll always work
f
@thdxr u mean when resolving the path to the CDK binary?
@Will Weaver thanks for sharing the details.
Feel free to switch back to yarn. I will try to reproduce this on my end.
w
Was going to see if there would be a simple tweak.
f
Yeah you can tweak this line
Copy code
return path.join(matches[1], ".bin", "cdk");
to
Copy code
return path.join(matches[1], "aws-cdk", "bin", "cdk");
And see if that fixes it.
Oh, make the change in the
dist
folder, not the
src
folder.
w
Seems to work
Copy code
pnpm -C db-schema exec sst start
That’s what I ran
Thanks!
f
Yup, this will unfortunately break on Windows. I need to put in some handling 🤔
w
Yeah, I don’t think that’s the right fix, just something that would work for me.
f
Yup. I will let u know after we release the fix.
t
yeah I meant if we call cdk using
npx cdk
it should work no matter what package manager they're using
w
This works for me
If that’s what you’re saying @thdxr
Replaced this
Will everyone have npx installed that’s using pnpm or yarn would be my only question? I’m not familiar enough. But I’ll leave that up to you all. Thanks for the help.
because there’s
npx cdk
,
yarn run cdk
and
pnpm exec cdk
t
cool! yeah npx is available for everyone with npm - we use it in other places to call binaries it's the only reliable method I've found
w
ok
If you’re already doing it then that works.
f
Gotcha! Lemme give
npx
a try.