[SOLVED] Netlify build fails because of `ethereumjs` - Host key verification failed

Hi devs! New Moralis user here working on a hackathon project :blush:

I am trying to run a build of my app, which right now is just a landing page and allows you to login/logout of metamask (so nothing super crazy is going on).

This is a snippet of the build script I saw in Netlify saying why the build failed…everything runs and works as normal locally. I am not sure why this is giving me so much trouble lol

4:36:45 AM: [2/4] Fetching packages...
4:36:47 AM: error Command failed.
4:36:47 AM: Exit code: 128
4:36:47 AM: Command: git
4:36:47 AM: Arguments: ls-remote --tags --heads ssh://[email protected]/ethereumjs/ethereumjs-abi.git
4:36:47 AM: Directory: /opt/build/repo
4:36:47 AM: Output:
4:36:47 AM: Host key verification failed.
4:36:47 AM: fatal: Could not read from remote repository.
4:36:47 AM: Please make sure you have the correct access rights
4:36:47 AM: and the repository exists.
4:36:47 AM: info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
4:36:54 AM: Error during Yarn install

Here is my React’s package.json file:

{
  "name": "helpmedev",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@emotion/react": "^11.4.1",
    "@emotion/styled": "^11.3.0",
    "@material-ui/core": "^4.12.3",
    "@mui/icons-material": "^5.0.1",
    "@mui/material": "^5.0.2",
    "@testing-library/jest-dom": "^5.11.4",
    "@testing-library/react": "^11.1.0",
    "@testing-library/user-event": "^12.1.10",
    "@typeform/embed-react": "^1.1.2",
    "@walletconnect/web3-provider": "^1.6.5",
    "moralis": "^0.0.68",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-moralis": "^0.2.4",
    "react-router-dom": "^5.3.0",
    "react-scripts": "4.0.3",
    "react-scroll": "^1.8.4",
    "styled-components": "^5.3.1",
    "web-vitals": "^1.0.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Has someone experienced this issue before or know how I can resolve it?

Thanks so much in advance!

Hey @cryptokid - thanks for the link! I am a little lost on how to go about this. Is this a github issue, or a netlify issue? I’m quite new to blockchain deployment, so apologies if this sounds not very informed…I am quite lost lol

short version: it tries to connect to GitHub over ssh and in order to do that you have to configure your operating system to be able to do that.

The fix could be as easy as opening a terminal window and trying to connect with ssh to github.com and then to accept the RSA key fingerprint

Thanks @cryptokid β€” Is there also a chance this has to do w/ the ethereumjs package too? I saw this answer on Netlify and was kind of similar to me: https://answers.netlify.com/t/hugo-site-deployment-failed-due-to-host-key-verification/783/5

I think it has to do with the fact that the ABI my project is calling in package-lock.json is outdated as stated on the github repo here: https://github.com/ethereumjs/ethereumjs-abi – right now this ethereumjs-abi is in a build error…but I am not sure how to edit this or fix this specifically.

Hi @InterstellarX

Could you share your gitignore file?

Someone in the hackathon discord mentioned clearing the cache and deleting the package-lock.json file might work. Any thoughts on this as well as a solution? https://stackoverflow.com/questions/64526838/build-fails-with-host-key-verification-failed-while-installing-node-modules

Hi @Yomoo β€” yes of course, here is the .gitignore file:

# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js

# testing
/coverage

# production
/build

# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*


Someone seemed to have the same error as me, but with Heroku, not netlify, so this solution is maybe 50% helpful since I’m using React + Netlify for right now: https://stackoverflow.com/questions/64526838/build-fails-with-host-key-verification-failed-while-installing-node-modules

I also noticed that my ethereumjs package dependencies in my package-lock.json file ssh into the repo as opposed to the https:// calls with everything else. Someone mentioned that in Netlify forum: https://answers.netlify.com/t/hugo-site-deployment-failed-due-to-host-key-verification/783

Is there a reason why this might have been imported with ssh rather than https://?

"node_modules/ethereumjs-abi": {
      "version": "0.6.8",
      "resolved": "git+ssh://[email protected]/ethereumjs/ethereumjs-abi.git#ee3994657fa7a427238e6ba92a84d0b529bbcde0",
      "license": "MIT",
      "optional": true,
      "peer": true,
      "dependencies": {
        "bn.js": "^4.11.8",
        "ethereumjs-util": "^6.0.0"
      }
    },
"ethereumjs-abi": {
      "version": "git+ssh://[email protected]/ethereumjs/ethereumjs-abi.git#ee3994657fa7a427238e6ba92a84d0b529bbcde0",
      "from": "[email protected]+https://github.com/ethereumjs/ethereumjs-abi.git",
      "optional": true,
      "peer": true,
      "requires": {
        "bn.js": "^4.11.8",
        "ethereumjs-util": "^6.0.0"
      },
      "dependencies": {
        "ethereumjs-util": {
          "version": "6.2.1",
          "resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-6.2.1.tgz",
          "integrity": "sha512-W2Ktez4L01Vexijrm5EB6w7dg4n/TgpoYU4avuT5T3Vmnw/eCRtiBrJfQYS/DCSvDIOLn2k57GcHdeBcgVxAqw==",
          "optional": true,
          "peer": true,
          "requires": {
            "@types/bn.js": "^4.11.3",
            "bn.js": "^4.11.0",
            "create-hash": "^1.1.2",
            "elliptic": "^6.5.2",
            "ethereum-cryptography": "^0.1.3",
            "ethjs-util": "0.1.6",
            "rlp": "^2.2.3"
          }
        }
      }
    },

The default is usually this for example:

"ethereumjs-account": {
      "version": "2.0.5",
      "resolved": "https://registry.npmjs.org/ethereumjs-account/-/ethereumjs-account-2.0.5.tgz",
      "integrity": "sha512-bgDojnXGjhMwo6eXQC0bY6UK2liSFUSMwwylOmQvZbSl/D7NXQ3+vrGO46ZeOgjGfxXmgIeVNDIiHw7fNZM4VA==",
      "optional": true,
      "peer": true,
      "requires": {
        "ethereumjs-util": "^5.0.0",
        "rlp": "^2.0.0",
        "safe-buffer": "^5.1.1"
      }
    },
    "ethereumjs-block": {
      "version": "1.7.1",
      "resolved": "https://registry.npmjs.org/ethereumjs-block/-/ethereumjs-block-1.7.1.tgz",
      "integrity": "sha512-B+sSdtqm78fmKkBq78/QLKJbu/4Ts4P2KFISdgcuZUPDm9x+N7qgBPIIFUGbaakQh8bzuquiRVbdmvPKqbILRg==",
      "optional": true,
      "peer": true,
      "requires": {
        "async": "^2.0.1",
        "ethereum-common": "0.2.0",
        "ethereumjs-tx": "^1.2.2",
        "ethereumjs-util": "^5.0.0",
        "merkle-patricia-tree": "^2.1.2"
      }
    },

I once faced the same problem. So I removed all .lock files, node_modules folder and called yarn install again. Then I manually edited in yarn.lock:

from:
"resolved": "git+ssh://[email protected]/ethereumjs/ethereumjs-abi.git#ee3994657fa7a427238e6ba92a84d0b529bbcde0"

to
"resolved": "https://registry.npmjs.org/ethereumjs-abi/-/ethereumjs-abi-0.6.8.tgz"

Hi @Yomoo β€” thanks so much, I am trying here and now am getting the same error. Here is a link to my package.json and project for reference: https://github.com/BrianHHough/HelpMeDev

Here is what I did in this section in package-lock.json β€” change the β€œresolved” part to what you mentioned:

From:

    "node_modules/ethereumjs-abi": {
      "version": "0.6.8",
      "resolved": "git+ssh://[email protected]/ethereumjs/ethereumjs-abi.git#ee3994657fa7a427238e6ba92a84d0b529bbcde0",
      "license": "MIT",
      "optional": true,
      "peer": true,
      "dependencies": {
        "bn.js": "^4.11.8",
        "ethereumjs-util": "^6.0.0"
      }
    },

To:

    "node_modules/ethereumjs-abi": {
      "version": "0.6.8",
      "resolved": "https://registry.npmjs.org/ethereumjs-abi/-/ethereumjs-abi-0.6.8.tgz",
      "license": "MIT",
      "optional": true,
      "peer": true,
      "dependencies": {
        "bn.js": "^4.11.8",
        "ethereumjs-util": "^6.0.0"
      }
    },

Here is the netlify build script for reference:

11:15:23 AM: > GPG signature looks good
11:15:23 AM: > Extracting to ~/.yarn...
11:15:24 AM: > Adding to $PATH...
11:15:24 AM: > Successfully installed Yarn 1.22.10! Please open another terminal where the `yarn` command will now be available.
11:15:24 AM: No yarn workspaces detected
11:15:24 AM: Started restoring cached node modules
11:15:24 AM: Finished restoring cached node modules
11:15:24 AM: Installing NPM modules using Yarn version 1.22.10
11:15:25 AM: yarn install v1.22.10
11:15:25 AM: warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
11:15:25 AM: [1/4] Resolving packages...
11:15:27 AM: [2/4] Fetching packages...
11:15:36 AM: error Command failed.
11:15:36 AM: Exit code: 128
11:15:36 AM: Command: git
11:15:36 AM: Arguments: ls-remote --tags --heads ssh://[email protected]/ethereumjs/ethereumjs-abi.git
11:15:36 AM: Directory: /opt/build/repo
11:15:36 AM: Output:
11:15:36 AM: Host key verification failed.
11:15:36 AM: fatal: Could not read from remote repository.
11:15:36 AM: Please make sure you have the correct access rights
11:15:36 AM: and the repository exists.
11:15:36 AM: info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
11:16:14 AM: Error during Yarn install
11:16:14 AM: Build was terminated: Build script returned non-zero exit code: 1
11:16:14 AM: Creating deploy upload records
11:16:14 AM: Failing build: Failed to build site
11:16:14 AM: Failed during stage 'building site': Build script returned non-zero exit code: 1
11:16:14 AM: Finished processing build request in 1m0.984179742s

Any ideas on what I might be missing here?

Netlify uses yarn, not npm. So you need to edit yarn.lock.

Read my message with instructions above again :man_factory_worker:

Hey @Yomoo β€” confirming I’m running everything via yarn in Netlify instead of npm. I’ve followed the documentation here for Create-React-App and your instructions above as well.

Build script error statement:

Can you please help me understand why it’s erroring because of this @walletconnect/web3-provider package. Error is here:

./node_modules/moralis/lib/browser/MoralisWalletConnectProvider.js
12:39:26 PM: Module not found: Can't resolve '@walletconnect/web3-provider' in '/opt/build/repo/node_modules/moralis/lib/browser'

Build script error statement is here:

12:38:11 PM: ────────────────────────────────────────────────────────────────
12:38:11 PM:   Netlify Build                                                 
12:38:11 PM: ────────────────────────────────────────────────────────────────
12:38:11 PM: ​
12:38:11 PM: ❯ Version
12:38:11 PM:   @netlify/build 18.13.7
12:38:11 PM: ​
12:38:11 PM: ❯ Flags
12:38:11 PM:   baseRelDir: true
12:38:11 PM:   buildId: 615b2dae03405c00087ea543
12:38:11 PM:   deployId: 615b2dae03405c00087ea545
12:38:11 PM: ​
12:38:11 PM: ❯ Current directory
12:38:11 PM:   /opt/build/repo
12:38:11 PM: ​
12:38:11 PM: ❯ Config file
12:38:11 PM:   No config file was defined: using default values.
12:38:11 PM: ​
12:38:11 PM: ❯ Context
12:38:11 PM:   production
12:38:11 PM: ​
12:38:11 PM: ────────────────────────────────────────────────────────────────
12:38:11 PM:   1. Build command from Netlify app                             
12:38:11 PM: ────────────────────────────────────────────────────────────────
12:38:11 PM: ​
12:38:11 PM: $ yarn build
12:38:11 PM: yarn run v1.22.10
12:38:11 PM: $ react-scripts build
12:38:13 PM: (node:1425) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at /opt/build/repo/node_modules/postcss-safe-parser/node_modules/postcss/package.json.
12:38:13 PM: Update this package.json to use a subpath pattern like "./*".
12:38:13 PM: (Use `node --trace-deprecation ...` to show where the warning was created)
12:38:13 PM: Creating an optimized production build...
12:39:26 PM: 
12:39:26 PM: Treating warnings as errors because process.env.CI = true.
12:39:26 PM: Most CI servers set it automatically.
12:39:26 PM: 
12:39:26 PM: Failed to compile.
12:39:26 PM: 
12:39:26 PM: ./node_modules/moralis/lib/browser/MoralisWalletConnectProvider.js
12:39:26 PM: Module not found: Can't resolve '@walletconnect/web3-provider' in '/opt/build/repo/node_modules/moralis/lib/browser'
12:39:26 PM: error Command failed with exit code 1.
12:39:26 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
12:39:26 PM: ​
12:39:26 PM: ────────────────────────────────────────────────────────────────
12:39:26 PM:   "build.command" failed                                        
12:39:26 PM: ────────────────────────────────────────────────────────────────
12:39:26 PM: ​
12:39:26 PM:   Error message
12:39:26 PM:   Command failed with exit code 1: yarn build

Could you try to install @walletconnect/web3-provider using yarn? This is an optional dependency, but very often you need to install it to build a project

Hey @Yomoo β€” confirming I have it installed. To confirm my errors, I am just working in a create-react-app template with simple sign-in button and sign-out button for metamask here: https://github.com/BrianHHough/moralistesting

After editing β€œresolved” line in yarn.lock

As soon as I edit the β€œresolved” line in the yarn.lock file, I get this error when installing node_modules:

yarn install
yarn install v1.22.11
warning ../../../../package.json: No license field
[1/4] πŸ”  Resolving packages...
[2/4] 🚚  Fetching packages...
error An unexpected error occurred: "Commit hash required".
info If you think this is a bug, please open a bug report with the information provided in "/.../.../.../.../.../testingmoralis/yarn-error.log".
info Visit https://yarnpkg .com/en/docs/cli/install for documentation about this command.

After editing β€œresolved” line in yarn.lock

This is what happens when I don’t edit the β€œresolved” statement. There is the issue with the ethereumjs/ethereumjs-abi package.

yarn install
yarn install v1.22.11
warning ../../../../package.json: No license field
[1/4] πŸ”  Resolving packages...
[2/4] 🚚  Fetching packages...
error Command failed.
Exit code: 128
Command: git
Arguments: ls-remote --tags --heads ssh://[email protected] .com/ethereumjs/ethereumjs-abi.git
Directory: /.../.../.../.../.../testingmoralis
Output:
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
info Visit https://yarnpkg .com/en/docs/cli/install for documentation about this command.

Sorry if I’m not understanding. I’ve built the project about 15 times trying to get this to work…lol


someone said that Thank you but I was able to solve this by updating npm to the latest version.

Thanks so much for guiding me in the right direction @Yomoo β€” it’s now live!!!

Here’s what worked for me:

  • installing @walletconnect/web3-provider
  • deleting node_modules, package.json, and /build folder
  • going into the yarn.lock file and editing that "resolved": "https://registry.npmjs.org/ethereumjs-abi/-/ethereumjs-abi-0.6.8.tgz" statement as well as the package name of the import to ethereumjs-abi-0.6.8
  • running yarn install
  • confirm there are no instances of ssh:// in yarn.lock
  • confirm the build script works with yarn build
  • send code to prod and launch on netlify!

It’s finally live for the hackathon β€” can’t wait to add in Moralis cloud functions and database attributes!

Well about 30+ builds later, finally have this working!! Thank you so much for your help, as well as @ cryptokid! Y’all rock :raised_hands:

Thanks for the help @cryptokid! you rock! I just shared above the steps I took to fix the issues I was having. So glad to have the app running now! Wooo!