https://pulumi.com logo
#general
Title
# general
m

many-spring-73557

10/20/2022, 8:41 PM
I want to make a shared library that I use across all pulumi projects. So I have a file like:
Copy code
import * as aws from "@pulumi/aws";

export function newRdsCpu(...) {
  new aws.cloudwatch.MetricAlarm(...);
}
I am hoping to import it with something like
import * as alarms from "../../pulumi-shared/alarms";
but when I do, I get
Cannot find module '@pulumi/aws'
If I add a
package.json
to
pulumi-shared
with
@pulumi/aws
in it then it works… but I don’t really want that file as an independent library. It should use the
@pulumi/aws
of whatever library is calling it. Does anyone have any suggestions for how to proceed? I am searching lots of TypeScript on how to import files from outside the root dir, but so far not having any luck.
a

ancient-policeman-24615

10/24/2022, 4:50 PM
I believe this is called a peer dependency in TS.
m

many-spring-73557

10/24/2022, 4:51 PM
Cool, I will look into that, thank you!
2 Views