Getting "Error: Cannot find module" when installing custom plugin #3387
|
We're creating a hardhat plugin for our app. It has a peer dependency I started a new project with The issue is that when importing both the peer dependency and the plugin in I've tried making the peer dependency a regular npm dependency in the plugin but it also yields the same result. I've tried removing the |
Replies: 2 comments 1 reply
|
By the way I've found similar issues that were resolved by running |
|
The "Cannot find module" error is correct: if you start a node repl and do I think the problem is that the The reason it did work for |
The "Cannot find module" error is correct: if you start a node repl and do
require("@zerodevapp/mock-server"), you'll get the same error.I think the problem is that the
pacakge.jsonfile in that package doesn't have a main entry, so it defaults toindex.js, which doesn't exist. Try adding"main": "dist/index.js"to that package.json.The reason it did work for
src/index.tsis (I think) that you are not doing anything with the imports, so norequires are generated. This is just a guess though, but it's very likely that's the explanation.