wing
wing copied to clipboard
Winglibs don't work with yarn or pnpm
I tried this:
try @winglibs/cognito with yarn as the package manager
This happened:
An error has occurred:
Failed to compile.
error: Unable to load "@cdktf/provider-aws": Module not found in "/private/tmp/a2/node_modules/@winglibs/cognito/platform/tfaws.w"
--> node_modules/@winglibs/cognito/platform/tfaws.w:3:1
|
3 | bring "@cdktf/provider-aws" as aws;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Unable to load "@cdktf/provider-aws": Module not found in "/private/tmp/a2/node_modules/@winglibs/cognito/platform/tfaws.w"
I expected this:
No response
Is there a workaround?
No response
Anything else?
No response
Wing Version
No response
Node.js Version
No response
Platform(s)
No response
Community Notes
- Please vote by adding a 👍 reaction to the issue to help us prioritize.
- If you are interested to work on this issue, please leave a comment.
Wing's ecosystem makes heavy use of peer dependencies. yarn does not have a builtin way to install peer dependencies. In addition to that, the now-default PnP mechanism that yarn uses is likely not something we're going to support anytime soon.
Given that, I don't think yarn is something we will support. npm is the only officially supported package manager for now while pnpm and bun both unofficially work as well.
A workaround if yarn must be used, it must not be with the PnP nodeLinker mode and any peer dependencies must be manually installed. For example, to use @winglibs/cognito you must run yarn add @winglibs/cognito @cdktf/provider-aws cdktf constructs
To close out this issue we should officially document package manager support level.
Does this issue only surface when installing a @winglib? Or are there issues if I install wing with yarn add (not globally)
In the meantime we might be able to soften the blow of these errors by raise a compiler warning if there's a yarn.lock or pnpm-lock.yaml file in the project, e.g.
Warning: We noticed you have a pnpm/yarn/bun lockfile. Wing hasn't been tested with package managers besides npm, so it may be unable to resolve dependencies to Wing libraries when using these tools. See https://github.com/winglang/wing/issues/6129 for more details.
this is ironic because the recommended tool for building wing itself was pnpm. https://www.winglang.io/contributing/start-here/development