`module-sync` export points at `./src/index.js`, so `require('datastore-core')` (and 13 other packages) fails

Open Beginner friendly
#381 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
node.js, typescript
Domain
release

Research direction

Start with the root "." export in packages/datastore-core/package.json, where "module-sync" points at ./src/index.js; compare it with packages/blockstore-core/package.json, which already uses ./dist/src/index.js. Apply the same one-line change to the root export of each affected packages/*/package.json, then confirm require("datastore-core") and the other named packages load after a build and pack/install. Done means all 14 packages match blockstore-core and the MODULE_NOT_FOUND error is gone.

Written by the indexing model from the issue text.

Description

In 14 of the 15 packages in this repo, the root "." export added in #369 points "module-sync" at "./src/index.js" instead of "./dist/src/index.js", so require() fails with MODULE_NOT_FOUND because published tarballs only include .ts files under src/.

npm i [email protected] [email protected]
node -e 'require("datastore-core")'

Actual output (Node.js v26.13.0):

node:internal/modules/cjs/loader:772
      throw e;
      ^

Error: Cannot find module '.../node_modules/datastore-core/src/index.js'
    at createEsmNotFoundErr (node:internal/modules/cjs/loader:1650:15)
    at finalizeEsmResolution (node:internal/modules/cjs/loader:1639:9)
    at resolveExports (node:internal/modules/cjs/loader:765:14)
    at Module._findPath (node:internal/modules/cjs/loader:832:31)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1596:27)
    at wrapResolveFilename (node:internal/modules/cjs/loader:1145:27)
    at defaultResolveImplForCJSLoading (node:internal/modules/cjs/loader:1169:10)
    at resolveForCJSWithHooks (node:internal/modules/cjs/loader:1196:12)
    at Module._load (node:internal/modules/cjs/loader:1370:5)
    at wrapModuleLoad (node:internal/modules/cjs/loader:261:19) {
  code: 'MODULE_NOT_FOUND',
  path: '.../node_modules/datastore-core'
}

Expected output: the module loads without error, matching require("blockstore-core") (whose root "module-sync" is "./dist/src/index.js") and subpath exports like require("datastore-core/memory").

Affected packages and versions tested (also reproduced on main at 58d2e06): [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]. Changing "module-sync": "./src/index.js" to "./dist/src/index.js" in packages/*/package.json fixes require() across all of them.

Credit: https://ucsbplse.github.io/

Dominant language
TypeScript
Stars
39
Forks
28
PR merge metrics
No merged PRs in 30d

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from ipfs/js-stores

All issues in ipfs/js-stores

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.