summary
- after installing the deps, cannot do npx hardhat actions because of
valid main entry
error
- for
hardhat-anvil
can work around that error by changing node_modules/@foundry-rs/hardhat-anvil/package.json
and change main
from dist/index.js
to dist/src/index.js
Steps to reproduce
install in sample hardhat project / existing project
npm i --save-dev @foundry-rs/hardhat
using @foundry-rs/hardhat
hardhat.config.js
require("@foundry-rs/hardhat");
// require("@foundry-rs/hardhat-anvil");
// require("@foundry-rs/hardhat-forge");
// require("@foundry-rs/easy-foundryup");
/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
defaultNetwork: "anvil",
anvil: {
url: "http://127.0.0.1:8545/",
launch: false,
},
solidity: "0.8.4",
};
try to run node with anvil
➜ integration git:(master) ✗ npx hardhat node
An unexpected error occurred:
Error: Cannot find module '/Users/m1/Desktop/integration/node_modules/@foundry-rs/hardhat/dist/index.js'. Please verify that the package.json has a valid "main" entry
try just hardhat
➜ integration git:(master) ✗ npx hardhat
An unexpected error occurred:
Error: Cannot find module '/Users/m1/Desktop/integration/node_modules/@foundry-rs/hardhat/dist/index.js'. Please verify that the package.json has a valid "main" entry
using @foundry-rs/hardhat-anvil
try using anvil
//hardhat.config.js
// require("@foundry-rs/hardhat");
require("@foundry-rs/hardhat-anvil");
// require("@foundry-rs/hardhat-forge");
// require("@foundry-rs/easy-foundryup");
/**
* @type import('hardhat/config').HardhatUserConfig
*/
module.exports = {
defaultNetwork: "anvil",
anvil: {
url: "http://127.0.0.1:8545/",
launch: false,
},
solidity: "0.8.4",
};
npm i --save-dev @foundry-rs/hardhat-anvil
➜ integration git:(master) ✗ npx hardhat node
An unexpected error occurred:
Error: Cannot find module '/Users/m1/Desktop/integration/node_modules/@foundry-rs/hardhat-anvil/dist/index.js'. Please verify that the package.json has a valid "main" entry
go to node_modules/@foundry-rs/hardhat-anvil/package.json and change main from dist/index.js
to dist/src/index.js
{
"name": "@foundry-rs/hardhat-anvil",
"version": "0.1.2",
"description": "Hardhat plugin for managing Anvil",
"homepage": "https://github.com/foundry-rs/hardhat",
"repository": "github:foundry-rs/hardhat",
"license": "MIT",
"main": "dist/src/index.js",
and get the value.url is missing error
➜ integration git:(master) ✗ npx hardhat node
Error in plugin @nomiclabs/hardhat-anvil: Anvil network config is invalid: value.url is missing
For more info run Hardhat with --show-stack-traces