Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yarn workspaces: Hardhat unable to locate node_modules for sub packages #87

Closed
tgunnoe opened this issue Feb 18, 2022 · 3 comments
Closed

Comments

@tgunnoe
Copy link
Contributor

tgunnoe commented Feb 18, 2022

Steps taken:
git clone https://github.com/nomiclabs/hardhat.git && cd hardhat

Drop test flake with dream2nix in repository, then:

git add flake.nix
nix flake show

you get a long list of packages, most of them are dependencies. and one defaultPackages for the root project.

nix build

build of the default package fails:


@nix { "action": "setPhase", "phase": "unpackPhase" }
  unpacking sources
  unpacking source archive /nix/store/7yz9x41x8rvdg8dmca52rmijzi243r73-5d7bixywasyxi7wgmacbx4w0sj77zkxi-source
  @nix { "action": "setPhase", "phase": "patchPhase" }
  patching sources
  @nix { "action": "setPhase", "phase": "d2nLoadFuncsPhase" }
  d2nLoadFuncsPhase
  @nix { "action": "setPhase", "phase": "d2nPatchPhase" }
  d2nPatchPhase
  @nix { "action": "setPhase", "phase": "configurePhase" }
  configuring
  installing: @changesets/cli
  installing: prettier
  installing: shelljs
  installing: typescript
  installing: wsrun
  @nix { "action": "setPhase", "phase": "buildPhase" }
  building
   
  > root@0.0.0 build /nix/store/lnmd1ka7rllp0p85pkchsjrr6i7phv23-root-0.0.0/lib/node_modules/root
  > tsc --build packages/hardhat-core packages/hardhat-docker packages/hardhat-ethers packages/hardhat-ethersc  an packages/hardhat-ganache packages/hardhat-solhint packages/hardhat-solpp packages/hardhat-truffle4 packag  es/hardhat-truffle5 packages/hardhat-vyper packages/hardhat-waffle packages/hardhat-web3 packages/hardhat-we  b3-legacy
   
  packages/hardhat-core/src/types/config.ts:15:25 - error TS2307: Cannot find module 'ethereumjs-util' or its   corresponding type declarations.
   
  15 import type { BN } from "ethereumjs-util";
                             ~~~~~~~~~~~~~~~~~
   
  packages/hardhat-core/src/types/config.ts:277:11 - error TS2503: Cannot find namespace 'Mocha'.
   
  277   mocha?: Mocha.MochaOptions;
                ~~~~~
   
  packages/hardhat-core/src/types/config.ts:285:10 - error TS2503: Cannot find namespace 'Mocha'.
   
  285   mocha: Mocha.MochaOptions;
               ~~~~~
   
  packages/hardhat-core/src/internal/util/abi-helpers.ts:1:22 - error TS2307: Cannot find module '@ethersproje  ct/abi' or its corresponding type declarations.
   
  1 import * as abi from "@ethersproject/abi";
                         ~~~~~~~~~~~~~~~~~~~~
   
  packages/hardhat-core/src/internal/hardhat-network/stack-traces/model.ts:1:29 - error TS2307: Cannot find mo  dule 'ethereumjs-util' or its corresponding type declarations.
   
  1 import { bufferToHex } from "ethereumjs-util";
                                ~~~~~~~~~~~~~~~~~
   
  packages/hardhat-core/src/internal/hardhat-network/stack-traces/message-trace.ts:1:30 - error TS2307: Cannot   find module '@ethereumjs/vm/dist/exceptions' or its corresponding type declarations.
   
  1 import type { VmError } from "@ethereumjs/vm/dist/exceptions";
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   
  packages/hardhat-core/src/internal/hardhat-network/stack-traces/message-trace.ts:2:25 - error TS2307: Cannot   find module 'ethereumjs-util' or its corresponding type declarations.
   
  2 import type { BN } from "ethereumjs-util";
...

On and on.

Inspecting the generated dream-lock.json file, I see that all the packages from the yarn.lock file are included in it. Even the sub-packages' dependencies. And the only repo package listed is again the root project, which only lists its devDependencies.

I think at minimum, the project's sub packages dependencies should be listed under the defaultPackage, not just the devDependencies.

@tgunnoe
Copy link
Contributor Author

tgunnoe commented Feb 18, 2022

Potentially related to #76

@tgunnoe
Copy link
Contributor Author

tgunnoe commented Feb 28, 2022

I made this "wrapper" as I noticed that dream2nix listed all of the dependencies from packages.json as buildable, so I made a simple package.json and only included hardhat and it builds.

https://github.com/tgunnoe/hardhat-wrapper

However, dependencies aren't listed as buildable anymore with the recent discoverer work in #76

@tgunnoe
Copy link
Contributor Author

tgunnoe commented Mar 12, 2022

Fixed basically with using lib2.

@tgunnoe tgunnoe closed this as completed Mar 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant