vercel-builder: Error building bcrypt with node-gyp

I started to have this issues with nuxt/vercel-builder 0.17.12.

[4/5] Building fresh packages...
--
13:29:39.104 | error /vercel/workpath1/node_modules/bcrypt: Command failed.
13:29:39.104 | Exit code: 127
13:29:39.104 | Command: node-pre-gyp install --fallback-to-build
13:29:39.104 | Arguments:
13:29:39.104 | Directory: /vercel/workpath1/node_modules/bcrypt
13:29:39.104 | Output:
13:29:39.104 | /bin/sh: node-pre-gyp: command not found
13:29:39.105 | info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
13:29:40.019 | Error: Command "yarn install" exited with 127
13:29:42.852 | Done with "nuxt.config.js"

Seems, for some reason the bcrypt installation started to fail after version 0.17.7. I made a test today using this version, and the project builded successfully.

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 11
  • Comments: 31 (5 by maintainers)

Commits related to this issue

Most upvoted comments

I think I found a workaround to the resolve this issue.

You can add vercel-build to your package.json to global install node-gyp, you’ll need to add a builds step before @nuxtjs/vercel-builder to ensure it gets installed in the correct order.

// vercel.json
{
  "version": 2,
  "builds": [
    {
      "src": "package.json",
      "use": "@vercel/node"
    },
    {
      "src": "nuxt.config.js",
      "use": "@nuxtjs/vercel-builder",
      "config": {
        "serverFiles": ["server-middleware/**"]
      }
    }
  ],
}
// package.json
{
  "scripts": {
    "vercel-build": "yarn global add node-gyp"
  }
}

It worked for me! I’m using the @supabase/supabase-js package that relies on node-gyp-build so my vercel-build command looks like yarn global add node-gyp-build.

I think I found a workaround to the resolve this issue.

You can add vercel-build to your package.json to global install node-gyp, you’ll need to add a builds step before @nuxtjs/vercel-builder to ensure it gets installed in the correct order.

// vercel.json
{
  "version": 2,
  "builds": [
    {
      "src": "package.json",
      "use": "@vercel/node"
    },
    {
      "src": "nuxt.config.js",
      "use": "@nuxtjs/vercel-builder",
      "config": {
        "serverFiles": ["server-middleware/**"]
      }
    }
  ],
}
// package.json
{
  "scripts": {
    "vercel-build": "yarn global add node-gyp"
  }
}

/bin/sh: node-pre-gyp: command not found is still a problem

For me the solution to add the pre build step doesn’t work. Wish we could get an answer from Nuxt or Vercel.

yeah. Me too!

I added in an update to a similar issue I faced in #468 – I used npm instead of yarn and it worked (and I’m not sure why)

For me the solution to add the pre build step doesn’t work. Wish we could get an answer from Nuxt or Vercel.

Any solution to this?

.vercelignore seems to be only for “what files to exclude when uploading” and not “what files to exclude when building”. So it still tries to install bcrypt which errors.

I thought .vercelignore is applied after building and not before. I will try out .vercelignore as it could be the solution to the problem. Thanks for the hint!

I will try that and leave a response here within the next 2 hours.