GYP ERR! build error. stack Error: 'make' failed with exit code 2

后端 未结 11 1366
自闭症患者
自闭症患者 2021-01-07 16:30

I am currently working on a nodejs web application I am having trouble pushing the application online with cloud foundry. I did some research on the errors and it seems that

相关标签:
11条回答
  • 2021-01-07 16:34

    For other people that stumble into this exact problem:

    In my case, the server node version was set to an older version in my package.json file than what my local environment was running. So check what you are running locally with:

    node --version
    -> 8.11.3
    

    Then look at your server setting in your package.json:

    {
      "name": "myapp",
      "version": "0.0.0",
      "private": true,
      "engines": {
        "node": "7.10.2" // <-- This is too old, set it to the node version you are running locally (8.11.3)
      },
    

    I hope this helps someone.

    0 讨论(0)
  • 2021-01-07 16:39

    This has been old yet consistent issue well documented at: https://github.com/nodejs/node-gyp/issues/809

    For me the error mentioned the version numbers like:

    gyp ERR! System Darwin 17.7.0
    gyp ERR! node -v v12.1.0
    gyp ERR! node-gyp -v v3.8.0
    

    After attempting all the possible combinations of solutions (modify ~/.npmrc, remove ~/.node-gyp, clear the npm cache, delete node_modules and even restart the system), what worked with me was downgrading the node.

    I believe the versions mentioned in the log for node and node-gyp are incompatible. So I reverted to an older node version which worked like a charm.

    npm install -g node@11.10.0
    

    There should be a clear documentation describing breaking changes and compatibility issues between the two.

    0 讨论(0)
  • 2021-01-07 16:41

    CentOS 6 users

    Node 10+ requires GCC4.9. And apparently CentOS 6 doesn't have it. You can use these commands before npm install as a workaround (tested with Node 11 NPM 6).

    yum install devtoolset-7
    source scl_source enable devtoolset-7
    

    Source: https://github.com/lovell/sharp/issues/1283

    0 讨论(0)
  • 2021-01-07 16:42

    If you are using NVM, you can also change to the version your package supports, like:

    nvm install 7.10.2
    nvm use 7.10.2
    
    0 讨论(0)
  • 2021-01-07 16:44

    I think delete this directory and clean the cache of npm is better:

    rm -rf ~/.node-gyp/
    rm -r node_modules/.bin/;
    rm -r build/
    npm cache clean
    

    and you can test

    npm install -g node-gyp
    

    and

    npm install -g node-pre-gyp
    

    finally:

    npm install <your module>
    
    0 讨论(0)
  • 2021-01-07 16:44

    I got the same problem when installed the gazebo gzweb. I found out that apt install nodejs install the "node" in the direction of "/usr/bin/". You can verify by which node. But node -v is still referring to "/usr/local/bin/node" which is a wrong version I failed to uninstall. Thus as my solution:

    rm -rf /usr/local/bin/node
    cp -i /usr/bin/node /usr/local/bin/
    cp -i /usr/bin/nodejs /usr/local/bin/
    

    Steps:

    sudo apt-get install npm npm install -g n n stable npm install npm@6.9.0 -g ln -s /usr/local/bin/npm /usr/bin/npm

    0 讨论(0)
提交回复
热议问题