question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Runtime error with rollup

See original GitHub issue

I am trying to use ethers for a browser-based app, built with rollup.

Package in package.json is:

  "dependencies": {
    "ethers": "^5.1.0",
    ...

The sample code from the doc:

  import { ethers } from "ethers";
  if (window["ethereum"] !== undefined) {
    const provider = new ethers.providers.Web3Provider(window["ethereum"]);
    const signer = provider.getSigner();
  } else {
    alert("no wallet");
  }

builds properly but gives a runtime error in browser console:

Uncaught (in promise) TypeError: Failed to resolve module specifier "util". Relative references must start with either "/", "./", or "../".

It seems that some Node-related bits are included in the build, despite having in rollup.config.js:

resolve({
      browser: true
})

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
malmodcommented, Jun 30, 2022

All resolved with new separate imports from 5.6

Thanks again for making this great lib!

0reactions
TonyVMcommented, Oct 1, 2022

https://docs.ethers.io/v5/getting-started

you are right dude, but in my opinion they should fix that issue and also give an explanation why the import { ethers } from ‘ethers’ doesn’t work, in my case I got an << Uncaught TypeError: Error resolving module specifier “ethers”. Relative module specifiers must start with “./”, “…/” or “/”. >> when using the import I previously mentioned, but then importing the cdn everything works fine.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rollup is getting failed with The internal session was ...
To solve this error: Manually set the flag aggrexist from 'X' to ' '. Review below note for function module "RSDDTREX_AFTER_UPGRADE_70X_73X",
Read more >
Rollup error: could not load a module from @babel/runtime ...
I found a workable solution. I just add the @rollup/plugin-alias plugin ... //other code const alias = require('@rollup/plugin-alias'); ...
Read more >
Error during installing Nakama Typescript Server Runtime
That's why I am trying to setup Nakama typescript server runtime using ... rollup.config.js to rollup.config.mjs it now gives below error:
Read more >
rollup/plugin-babel
Start using @rollup/plugin-babel in your project by running `npm i ... @babel/runtime/helpers/get ) and Rollup will only exclude modules ...
Read more >
Hotfix rollup 2784931 is available for Microsoft Dynamics ...
When you try to open the Cashier list in Microsoft Dynamics RMS Store Operations Manager, you receive the following error message: Runtime Error...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found