solana: package.json references `index.browser.cjs.js` which does not exist

Problem

Pull Request #21940 introduced a bug where package.json points to a file that does not exist in the browser ./lib/index.cjs.js field.

While trying to use this library in an environment such as react-native, you see the following error:

While trying to resolve module `@solana/web3.js` from file `...`, the package `.../node_modules/@solana/web3.js/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`.../node_modules/@solana/web3.js/lib/index.browser.cjs.js`.

Proposed Solution

Revert #21940 or update rollup config to output a .browser.cjs.js file.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 15 (7 by maintainers)

Most upvoted comments

I am having similar issues and I’ve tried both version 1.37.0 and 1 40.0 and all show errors

It says it’s missing a .cjs file and also main.js is missing

Error: Cannot find module ‘/…/node_modules/@solana/web3.js/lib/index.cjs.js’. Please verify that the package.json has a valid “main” entry