yarn 3 + yarn workspace + webpack 5 + ProviderPlugin doesn't work well
See original GitHub issueBug report
What is the current behavior? The build fails with the following messages,
ERROR in ../../.yarn/cache/axios-npm-0.27.2-dbe3a48aea-38cb754046.zip/node_modules/axios/lib/defaults/index.js 24:20-27
Module not found: Error: Can't resolve 'process/browser' in '/Users/asdf/Documents/GitHub/yarn2-webpack5-sandbox/.yarn/cache/axios-npm-0.27.2-dbe3a48aea-38cb754046.zip/node_modules/axios/lib/defaults'
resolve 'process/browser' in '/Users/asdf/Documents/GitHub/yarn2-webpack5-sandbox/.yarn/cache/axios-npm-0.27.2-dbe3a48aea-38cb754046.zip/node_modules/axios/lib/defaults'
Parsed request is a module
using description file: /Users/asdf/Documents/GitHub/yarn2-webpack5-sandbox/.yarn/cache/axios-npm-0.27.2-dbe3a48aea-38cb754046.zip/node_modules/axios/package.json (relative path: ./lib/defaults)
resolve as module
request is not managed by the pnpapi
axios tried to access process. While this module is usually interpreted as a Node builtin, your resolver is running inside a non-Node resolution context where such builtins are ignored. Since process isn't otherwise declared in axios's dependencies, this makes the require call ambiguous and unsound.
Required package: process
Required by: /Users/asdf/Documents/GitHub/yarn2-webpack5-sandbox/.yarn/cache/axios-npm-0.27.2-dbe3a48aea-38cb754046.zip/node_modules/axios/lib/defaults/
@ ../../.yarn/cache/axios-npm-0.27.2-dbe3a48aea-38cb754046.zip/node_modules/axios/lib/axios.js 7:15-36
@ ../../.yarn/cache/axios-npm-0.27.2-dbe3a48aea-38cb754046.zip/node_modules/axios/index.js 1:0-39
@ ./src/index.js 1:0-26
webpack 5.73.0 compiled with 1 error in 635 ms
request is not managed by the pnpapi seems to tell that it’s relevant to yarn 3 environment.
If the current behavior is a bug, please provide the steps to reproduce. clone this repo and build following the guideline. Then you can see the error message above.
What is the expected behavior?
The build succeeds and process get resolved correctly.
If you remove the new ProviderPlugin(...) line, then the build will succeed without the wrong process resolution.
If you take app package out of the workspace to make it stand alone, then the build will succeed and process will get resolved properly.
Other relevant information: webpack version: 5.73.0 Node.js version: v.16.13.2 Operating System: Mac OS Big Sur 11.6 Additional tools:
Issue Analytics
- State:
- Created a year ago
- Comments:6 (3 by maintainers)

Top Related StackOverflow Question
@alexander-akait I’m sorry I’m not sure I understand your answer in the right way.
Do you mean that I shouldn’t use
axiosin browsers? I installedprocessin the package. And this solution worked well without yarn workspace. Only when I put my package inside a workspace, that error happens. I don’t know if using axios in browser is something we need to avoid, but I think that it would be better to fix the situation that some errors happen only with yarn workspace at least.Kind of the same issue:
Required package:
httplike this other 10 logs. and then it ends with: