Error: Cannot find module 'create-hash'

I use the SDK as normal.
I oz compile.
Then sometimes suddenly my console errors when I want to use oz commands.
I got rid of the problem by deleting my node_modules folder and npm reinstalling them. The oz commands then worked as they should for some time.
But then the error Cannot find module 'create-hash' reappeared. It is hard to reason about any steps that might have led up to this error. I did not delete or install anything new into the project folder in the interim.

This must have something to do with the node_modules/ directory though, as every time I delete it and npm install the error goes away.

I should also mention that at certain times I had a oz session configured - maybe something happened due to that.

:computer: Environment
@openzeppelin/cli@2.5.3

nothing else

1 Like

Hi @gitpusha,

Looking at your packages installed, you currently have @openzeppelin/contracts rather than @openzeppelin/contracts-ethereum-package:

https://docs.openzeppelin.com/sdk/2.5/linking
Make sure you install @openzeppelin/contracts-ethereum-package and not the vanilla @openzeppelin/contracts . The latter is set up for general usage, while @openzeppelin/contracts-ethereum-package is tailored for being used with the OpenZeppelin SDK. This means that its contracts are already set up to be upgradeable.

Though use version 2.2.3 due to https://github.com/OpenZeppelin/openzeppelin-contracts-ethereum-package/issues/70

oz link @openzeppelin/contracts-ethereum-package@2.2.3

Other than the above, there is nothing that I am aware of which would cause the issue you are seeing.

I have tried recreating but haven’t been able to reproduce unfortunately (using Windows Subsystem for Linux).

$ npm list --depth=0
deep@1.0.0 /mnt/c/Users/andre/Documents/projects/forum/deep
β”œβ”€β”€ @openzeppelin/contracts@2.3.0
β”œβ”€β”€ @openzeppelin/upgrades@2.5.3
β”œβ”€β”€ @truffle/hdwallet-provider@1.0.22
└── dotenv@8.2.0
$ npm list create-hash
deep@1.0.0 /mnt/c/Users/andre/Documents/projects/forum/deep
β”œβ”€β”¬ @openzeppelin/upgrades@2.5.3
β”‚ └─┬ web3@1.2.1
β”‚   └─┬ web3-eth@1.2.1
β”‚     └─┬ web3-eth-accounts@1.2.1
β”‚       └─┬ crypto-browserify@3.12.0
β”‚         β”œβ”€β”¬ browserify-sign@4.0.4
β”‚         β”‚ β”œβ”€β”€ create-hash@1.2.0  deduped
β”‚         β”‚ └─┬ parse-asn1@5.1.5
β”‚         β”‚   └── create-hash@1.2.0  deduped
β”‚         β”œβ”€β”€ create-hash@1.2.0  deduped
β”‚         └─┬ public-encrypt@4.0.3
β”‚           └── create-hash@1.2.0  deduped
└─┬ @truffle/hdwallet-provider@1.0.22
  β”œβ”€β”¬ bip39@2.6.0
  β”‚ β”œβ”€β”€ create-hash@1.2.0
  β”‚ └─┬ pbkdf2@3.0.17
  β”‚   β”œβ”€β”€ create-hash@1.2.0  deduped
  β”‚   └─┬ create-hmac@1.1.7
  β”‚     └── create-hash@1.2.0  deduped
  β”œβ”€β”¬ ethereumjs-tx@1.3.7
  β”‚ └─┬ ethereumjs-util@5.2.0
  β”‚   └── create-hash@1.2.0  deduped
  β”œβ”€β”¬ ethereumjs-util@6.1.0
  β”‚ β”œβ”€β”€ create-hash@1.2.0  deduped
  β”‚ └─┬ secp256k1@3.7.1
  β”‚   β”œβ”€β”€ create-hash@1.2.0  deduped
  β”‚   └─┬ drbg.js@1.0.1
  β”‚     β”œβ”€β”¬ browserify-aes@1.2.0
  β”‚     β”‚ └── create-hash@1.2.0  deduped
  β”‚     └── create-hash@1.2.0  deduped
  β”œβ”€β”¬ ethereumjs-wallet@0.6.3
  β”‚ β”œβ”€β”¬ bs58check@2.1.2
  β”‚ β”‚ └── create-hash@1.2.0  deduped
  β”‚ └─┬ hdkey@1.1.1
  β”‚   └─┬ coinstring@2.3.0
  β”‚     └── create-hash@1.2.0  deduped
  └─┬ web3-provider-engine@14.0.6 (git+https://github.com/trufflesuite/provider-engine.git#3538c60bc4836b73ccae1ac3f64c8fed8ef19c1a)
    β”œβ”€β”¬ eth-block-tracker@3.0.1
    β”‚ └─┬ ethereumjs-util@5.2.0
    β”‚   └── create-hash@1.2.0  deduped
    β”œβ”€β”¬ eth-json-rpc-infura@3.2.1
    β”‚ └─┬ eth-json-rpc-middleware@1.6.0
    β”‚   β”œβ”€β”¬ eth-tx-summary@3.2.4
    β”‚   β”‚ └─┬ ethereumjs-util@5.2.0
    β”‚   β”‚   └── create-hash@1.2.0  deduped
    β”‚   └─┬ ethereumjs-util@5.2.0
    β”‚     └── create-hash@1.2.0  deduped
    β”œβ”€β”¬ eth-sig-util@1.4.2
    β”‚ └─┬ ethereumjs-util@5.2.0
    β”‚   └── create-hash@1.2.0  deduped
    β”œβ”€β”¬ ethereumjs-block@1.7.1
    β”‚ β”œβ”€β”¬ ethereumjs-util@5.2.0
    β”‚ β”‚ └── create-hash@1.2.0  deduped
    β”‚ └─┬ merkle-patricia-tree@2.3.2
    β”‚   └─┬ ethereumjs-util@5.2.0
    β”‚     └── create-hash@1.2.0  deduped
    β”œβ”€β”¬ ethereumjs-util@5.2.0
    β”‚ └── create-hash@1.2.0  deduped
    └─┬ ethereumjs-vm@2.6.0
      β”œβ”€β”¬ ethereumjs-account@2.0.5
      β”‚ └─┬ ethereumjs-util@5.2.0
      β”‚   └── create-hash@1.2.0  deduped
      └─┬ ethereumjs-block@2.2.0
        └─┬ ethereumjs-util@5.2.0
          └── create-hash@1.2.0  deduped
1 Like

Thanks for trying your best. I swapped my @openzeppelin/contracts for the @openzeppelin/contracts-ethereum-package@2.2.3, as per your advice.

1 Like