Heroku:错误:无法找到模块node-gyp

时间:2018-03-24 19:43:49

标签: node.js heroku sharp

昨天(03/23/18)开始在heroku部署上出现此错误,并且不知道为什么。没有包更改或与节点模块有关的任何内容。 yarn install

会抛出此错误

任何帮助将不胜感激。

    [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

1 个答案:

答案 0 :(得分:2)

问题是由于NPM发布了破坏的更新。从5.8.0回滚到5.7.1

- EDIT-- 要在Heroku上锁定NPM版本,请将以下代码添加到package.json文件中。 "engines": { "npm": "5.7.1" ...other stuff },