Search code examples
reactjsgitgatsbygatsby-plugin

Gatsby fails at develop when cloning git repository


My gatsby project works perfectly when I create new project and follow these steps: https://www.gatsbyjs.com/docs/quick-start/ But when I try to clone another repository such as:

  1. git clone https://repositoryurl
  2. npm install -g gatsby-cli
  3. npm install
  4. gatsby develop

It fails with error Failed at the pngquant-bin@5.0.2 postinstall script. I tried different repositories, all the solutions which I found on internet but nothing helps. Before you ask running npm install libpng-dev gives npm ERR! 404 Not Found - GET https://registry.npmjs.org/libpng-dev - Not found. Running npm install pngquant-bin gives npm ERR! pngquant-bin@6.0.0 postinstall node lib/install.js My node version: v12.18.3. My npm version: 6.14.6. I use Windows 10.


Solution

  • You need to install windows-build-tools. Just run:

    npm install --global windows-build-tools --vs2015
    

    Many Gatsby plugins and themes require building native Node.js modules, e.g. Sharp (a common Gatsby dependency used for image processing, like the one breaking your code). Upon installing this package, it downloads and installs Visual C++ Build Tools 2015, provided free of charge by Microsoft. These tools are required to compile popular native modules. It will also install Python 2.7, configuring your machine, and npm appropriately.