On March 29, 2025, while developing the Lite MCP SDK, I installed the local SDK in a test project and ran into an entry point resolution error. The package still had the placeholder name your-sdk-name. That problem taught me to separate two questions: is the package installed, and does it expose the entry point the caller is using?1
Why can't I import a file that exists?
Here's an excerpt from the error I saved:12
Package subpath './index.cjs' is not defined by "exports"
Here ./index.cjs is a subpath accessed through the package name. For example, when loading your-sdk-name/index.cjs, Node checks whether the package exposes that entry point in exports. A file can exist on disk without being accessible through that package subpath.3
This is the package.json configuration I committed that evening, with fields unrelated to entry points omitted:4
{
"type": "module",
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
}
}
This exposes the root entry point, ".". When a caller imports from the package name, import and require each select their corresponding build artifact. The configuration doesn't expose the ./index.cjs subpath. Pointing main at a file doesn't automatically make that filename an accessible subpath either.3
Looking back at the integration scripts, the two ends tested different things. The test project installed the local package with file:../javascript. The server resolved the entry point with require.resolve("your-sdk-name") before loading it with require. The client, however, imported the source files for Client and SSEClientTransport directly through relative paths. Even a working client couldn't tell me which classes other people could import from the package name. In fact, the root entry point on the evening of March 29 didn't export SSEClientTransport. I added it the next day.5
Match the import to the published entry point
If the caller needs only the SDK's public interface, import from the package name and let the package's conditional exports select the artifact. For the configuration above, that looks like this:
// ESM 调用方
import { Client } from "your-sdk-name";
// CommonJS 调用方
const { Client } = require("your-sdk-name");
If you really want to provide another entry point, declare the subpath explicitly in exports and check that the published package includes the target file. To debug this, inspect the caller's import path, the installed version's package.json, and its build artifacts together. The configuration in the source repository alone doesn't tell you what the consumer installed.3
Check the package name too. On the evening of March 31, I changed the install command and both the import and require examples in the higher-level wrapper's README from lite-mcp to the actual package name, litemcpjs. On April 2 I had to fix package.json once more to match its entry point filenames to Rollup's output. Either mistake would stop a reader copying the examples before they reached the SDK's own code.6
Wilson-Edwards gave an example in a Zhihu answer. His library assigned files to import and require under the root entry point "." and added a separate "./package.json": "./package.json" entry. This lets callers load the library by package name and read its metadata through package-name/package.json.7
Once the entry point resolves, running the artifact can still produce ReferenceError: exports is not defined. That's a separate module format issue, which I also hit during the same development work. See Debugging mixed ESM and CommonJS artifacts.
References
Footnotes
-
CaiBorui. (2025, March 29). Fixing Module Import Errors in Node.js [Private development conversation with Cursor retained by the author]. The afternoon discussion covered package exports and CommonJS and ESM loading, including a pasted proposal to remove the
__esModulemarker. The evening question concerned building ESM and CJS together with Rollup. Dates were checked against the corresponding response times in Beijing time. The error path and search history also draw on notes added by the author on November 17, 2026. ↩ ↩2 -
Google. (n.d.). Package subpath and exports is not defined [Two searches saved by the author]. Package subpath not exposed, undefined exports variable. ↩
-
Node.js contributors. (n.d.). Modules: Packages [Pinned Node.js v22.14.0 documentation, “package.json and file extensions”, “Subpath exports”, and “Conditional exports”]. Node.js. https://nodejs.org/download/release/v22.14.0/docs/api/packages.html ↩ ↩2 ↩3
-
CaiBorui [S2thend]. (2025, March 29). Lite MCP SDK package exports and build configuration [Historical snapshot
3026728]. GitHub. package.json, rollup.config.js. ↩ -
CaiBorui [S2thend]. (2025, March 29–30). Lite MCP SDK local installation, integration testing, and entry point exports [Source code and commit]. GitHub. Test project dependency, server-side loading by package name, direct client-side source imports, adding the client transport export. ↩
-
CaiBorui [S2thend]. (2025, March 31–April 2). Corrections to litemcpjs usage examples and package entry points [Git commits]. GitHub. Correcting the package name in the README, correcting build artifact paths. ↩
-
Wilson-Edwards. (2022, December 21). 开发npm包如何同时适配commonJS和esModule? [How can an npm package support both CommonJS and ES modules? Answer edited on this date, including a single-file library's
package.jsonexample]. Zhihu. Answer to the original question. ↩