Missing exports field in package.json causes Yarn PnP resolution failures for subpath imports
#56,858 opened on 2026年2月4日
説明
Reproduction link
https://github.com/OrlovAlexei/antd-exports-issue
Steps to reproduce
1. Clone the repository
Clone the repository and follow the instructions in the README
git clone https://github.com/OrlovAlexei/antd-exports-issue.git
cd antd-exports-issue
2. Install dependencies
yarn install
3. Build the library and create a tarball
yarn build:lib
cd packages/lib && yarn pack && cd ../..
4. Install dependencies again (to pick up the tarball)
yarn install
5. Run the tests
cd packages/app && yarn vitest run
What is expected?
Yarn PnP should be able to resolve subpath imports like antd/es/input/Search when antd has proper exports field configuration.
What is actually happening?
Yarn PnP fails with "Qualified path resolution failed" error because antd doesn't declare these paths in exports.
| Environment | Info |
|---|---|
| antd | 6.2.3 |
| React | 18.2.0 |
| System | Lunux |
| Browser | N/A (Node.js/Yarn PnP) |
When consuming libraries that re-export antd components from subpaths (e.g., antd/es/input/Search), Yarn PnP fails to resolve these paths because it strictly validates package exports through the exports field. The error occurs when a library imports from antd subpaths and is consumed as a tarball/npm package (not workspace).
Suggested Solution
Add exports field to package.json:
{
"exports": {
".": {
"import": "./es/index.js",
"require": "./lib/index.js",
"types": "./es/index.d.ts"
},
"./es/_": "./es/_",
"./lib/_": "./lib/_",
"./locale/_": "./locale/_",
"./dist/reset.css": "./dist/reset.css",
"./package.json": "./package.json"
}
}
Additional Context
• Issue only reproduces when library is installed from npm/tarball, not with workspace:* • This affects real-world usage where design systems are published to npm • Related to modern ESM/Node.js module resolution standards • Similar issue: https://github.com/ant-design/ant-design/issues/46413