-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Self-service
- I'd be willing to implement a fix
Describe the bug
The issue is a bit bizarre to start with. In a repo that uses docusarus I tried bumping yarn from 4.1.1 to the newest 4.10.3 and I encountered this bug.
In docusaurus docs I import typescript for an interactive playground. The docs build just fine. However, upgrading yarn yields the following error, coming from webpack:
[ERROR] Client bundle compiled with errors therefore further build is impossible.
Module not found: Error: Can't resolve 'module' in '/Users/user/my-website/node_modules/typescript/lib'
Clearly something is wrong as there's no module
file or module
dir in typescript/lib
and this lookup doesn't make sense.
When I went into further debugging and I did the following change to the package.json
of TS package:
"browser": {
"fs": false,
"os": false,
"path": false,
"crypto": false,
"buffer": false,
"source-map-support": false,
"inspector": false,
"perf_hooks": false,
+ "typescript": "./lib/module.js"
},
The build worked but then it failed at runtime

What's interesting here is that pnp
is mentioned in the stack trace but my setup doesn't use pnp. My guess would be that something in the environment in yarn changed so that pnp is used even when it shouldn't.
To reproduce
To create a blank docusarus project:
npx create-docusaurus@latest my-website classic --typescript --skip-install
.
Setup yarn in repository:
cd my-website
yarn set version 4.1.1
yarn config set nodeLinker node-modules
yarn config set enableGlobalCache false
Add typescript as a dependency:
yarn add typescript@5.8.3
Add the following in the top level of src/pages/index.tsx
to include typescript in the built docs:
// src/pages/index.tsx
import ts from "typescript";
console.log(
ts.transpileModule("function foo():void {}", {
compilerOptions: { sourceMap: true },
}).sourceMapText
);
Run the build and see that it passes without errors:
yarn build
Bump yarn version to 4.10.3 and make sure to wipe all the caches:
yarn set version 4.10.3
rm -fr build .docusaurus node_modules .yarn yarn.lock
Run yarn build
again to get the error.
Environment
System:
OS: macOS 15.6
CPU: (14) arm64 Apple M4 Pro
Binaries:
Node: 22.14.0 - /private/var/folders/jg/m839qn593nn7w_h3n0r9k25c0000gn/T/xfs-4e799f27/node
Yarn: 4.10.3 - /private/var/folders/jg/m839qn593nn7w_h3n0r9k25c0000gn/T/xfs-4e799f27/yarn
npm: 10.9.2 - /Users/bigpoppe/.nvm/versions/node/v22.14.0/bin/npm
Additional context
No response