Search code examples
node.jsherokusharp

Heroku: Error: Cannot find module node-gyp


Started getting this error on heroku deployments yesterday (03/23/18) and have no idea why. No package changes or anything relating to node modules. This error gets thrown on yarn install

Any help would be appreciated.

    [4/4] Building fresh packages...
    error An unexpected error occurred: "/tmp/build_0ee997c3e293524b58e17ee6d643ada3/blog/node_modules/sharp: Command failed.
    Exit code: 1
    Command: sh
    Arguments: -c node-gyp rebuild
    Directory: /tmp/build_0ee997c3e293524b58e17ee6d643ada3/blog/node_modules/sharp
    Output:
    module.js:545
      throw err;
      ^
    Error: Cannot find module '/tmp/build_0ee997c3e293524b58e17ee6d643ada3/.heroku/node/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js'
      at Function.Module._resolveFilename (module.js:543:15)
      at Function.Module._load (module.js:470:25)
      at Function.Module.runMain (module.js:690:10)
      at startup (bootstrap_node.js:194:16)
      at bootstrap_node.js:666:3".
         info If you think this is a bug, please open a bug report with the information provided in "/tmp/build_0ee997c3e293524b58e17ee6d643ada3/blog/yarn-error.log".
         info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
    error An unexpected error occurred: "Command failed.
    Exit code: 1
    Command: sh
    Arguments: -c cd blog && yarn install && yarn deploy && cd ..
    Directory: /tmp/build_0ee997c3e293524b58e17ee6d643ada3
    Output:
    ".
         info If you think this is a bug, please open a bug report with the information provided in "/tmp/build_0ee997c3e293524b58e17ee6d643ada3/yarn-error.log".
         info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    error An unexpected error occurred: "Command failed.
    Exit code: 1
    Command: sh

Solution

  • The problem was due to NPM releasing a broken update. Rolled back from 5.8.0 to 5.7.1.

    --EDIT-- To lock an NPM version on Heroku, add the following code to your package.json file. "engines": { "npm": "5.7.1" ...other stuff },