Error installing node-gyp on ubuntu

前端 未结 12 1078
执念已碎
执念已碎 2020-12-02 09:39
npm http 200 https://registry.npmjs.org/weak/-/weak-0.2.2.tgz
npm http GET https://registry.npmjs.org/bindings
npm http 304 https://registry.npmjs.org/bindings

>         


        
12条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-02 10:06

    Here are the steps to install node-gyp successfully on a Ubuntu system:

    1.First of all, install the "make" build tool in Ubuntu with the following commands:

    sudo apt-get update && \
    sudo apt-get install build-essential software-properties-common -y;
    

    2. Then you need to install the a proper C/C++ compiler toolchain. We will be installing GCC here with the following commands:

    sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y && \
    sudo apt-get update && \
    sudo apt-get install gcc-snapshot -y && \
    sudo apt-get update && \
    sudo apt-get install gcc-6 g++-6 -y && \
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-6 60 --slave 
    /usr/bin/g++ g++ /usr/bin/g++-6 && \
    sudo apt-get install gcc-4.8 g++-4.8 -y && \
    sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 60 --slave 
    /usr/bin/g++ g++ /usr/bin/g++-4.8;
    

    3. Install python 2.7 version. (Note: Python 3 is not supported by node-gyp).

    sudo apt update
    sudo apt upgrade
    sudo apt install python2.7 python-pip
    

    4. And finally install, node-gyp npm package:

    npm install -g node-gyp
    

    Additional but not important: If you have any atom keyboard-layout related issue with node-gyp then install the following one more package:

    sudo apt-get install libxkbfile-dev
    

    Thats all! It should be working fine now.

提交回复
热议问题