I'm having trouble including the NonceManager class in my hardhat config:
I can't use import statements in the file it seems. So I've tried
const NonceManager = require("@ethersproject/experimental/nonce-manager");
and
const { NonceManager } = require("@ethersproject/experimental/nonce-manager");
But I get the error:
Error: Cannot find module '@ethersproject/experimental/nonce-manager'
My devDependencies in package.json include:
"@ethersproject/experimental": "^5.6.0", and "ethers": "^5.6.0",
Not sure what I'm doing wrong here. For context, here is the file and its exports: https://github.com/ethers-io/ethers.js/blob/master/packages/experimental/lib/nonce-manager.js
Thanks!
Have you made sure to npm install?
When you clone an existing project, the node_modules folder is often in the .gitignore to save space and download time. This means that you should cd to your project folder and run npm install, which will download any missing packages.
EDIT: It appears you're just using the wrong import/require. Here is the correct way to import it:
// Node
const { NonceManager } = require("@ethersproject/experimental");
// ESM/TypeScript
import { NonceManager } from "@ethersproject/experimental";
See the bottom of https://docs.ethers.io/v5/api/experimental/