Problem with node_modules in yarn 2 workspaces: Cannot find plugin 'x'
See original GitHub issueDescribe the issue When working with yarn 2 workspaces, node_modules are not located in the workspace-folder but in the root of the project.
architect throws an error when building:
- Cannot find plugin 'architect/plugin-remix'! Are you sure you have installed or created it correctly?
Error: Plugin error:
- Cannot find plugin 'architect/plugin-remix'! Are you sure you have installed or created it correctly?
at format (/src/converter/node_modules/@architect/inventory/src/lib/error-fmt.js:15:13)
I traced the error back to @architect/inventory to the plugins-section: https://github.com/architect/inventory/blob/848958571ccad74753ee336dc47364f1298287dc/src/config/pragmas/plugins.js#L103
There it checks via cwd
where the plugin may be.
Maybe there is a way to adjust the cwd
for this process?
Steps to reproduce
- Create a project where you would use yarn 2
- Add workspaces to the package.json root:
workspaces: [ "app/*" ]
- Add a workspace where architect lives in
app/package.json
- Install architect and a plugin
- Start the app
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:8 (3 by maintainers)
Top Results From Across the Web
yarn: cannot find module - typescript - Stack Overflow
This error is coming from the linter; I think it's checking inside the package lock file (which does not exist as yarn is...
Read more >Plug'n'Play | Yarn - Package Manager
An overview of Plug'n'Play, a powerful and innovative installation strategy for Node.
Read more >Advanced package manager features for npm, Yarn, and pnpm
The problem with the traditional node_modules approach; Yarn Berry's ... You have to specify missing dependencies in the package.json ...
Read more >Support yarn workspaces (better indexing of node_modules ...
If you encounter problems with import resolving, make sure that your yarn version is up to date 3.2.2 had a bug where the...
Read more >Building a Monorepo with Yarn 2 - Heroku Blog
Yarn 2 is officially supported by Heroku. Here's a popular use case for Yarn enhanced by Yarn 2: using workspaces to manage dependencies...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @ryanblock,
Thanks for the fast response.
These are the steps:
yarn dlx create-remix@latest
yarn install
anywhere in the repositoryyarn build
in the remix project you’ll get many dependency error.yarnrc.yml
that resolves these mistakes (it is better to resolve them in the packages but unfortunately I don’t have free time for a PR right now)yarn dev
which usingarc sandbox
internally you encounter many errors like (cannot find moduleX
innode_modules
)So to conclude architect packages have 2 issues that both are not standard Node.js practice and cause modern package managers to break or throw warnings:
node_modules
instead of relying on the runtime to resolve themFinally, I’m not sure that using yarn pnp or pnpm is a good idea in AWS lambda (definitely possible) but I know that users will definitely use them for their local development.
I had the similar issue using the remix architect template.
Many developers use yarn v2 pnp for package management and I think this is one of
architect
’s most significant shortcomings in terms of DevX, especially for Remix developers.Custom module resolution logic always leads to unexpected behavior for your users. IMHO, simply using
require.resolve
for requiring packages is much better.