Search code examples
node.jsgitvisual-studio-codenpmnwjs

Git Error -4058 while trying to npm install nw-builder


I just created a new folder on my Desktop and loaded it to VSCode so I can start building/learning about NW.js. The first thing I've done was to open VSCode Terminal and execute npm init -y, then I've proceeded to run npm install nw@sdk. No error whatsoever.

Now my new folder has a package.json, a package-lock.json, and node_modules folder.

package.json content:

{
  "name": "rename-merra-app",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "nw": "^0.62.1-sdk"
  }
}

When I try to run npm install nw-builder --save-dev as the reference suggests @ https://www.npmjs.com/package/nw-builder, I got the following error:

npm ERR! code ENOENT
npm ERR! syscall spawn git
npm ERR! path git
npm ERR! errno -4058
npm ERR! enoent An unknown git error occurred
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Misharin\AppData\Local\npm-cache\_logs\2022-03-23T03_41_13_504Z-debug-0.log

Error 4058 after npm install nw-builder --save-dev

The .log file can be found here: https://pastebin.com/cZAmugRF

I've tried the following:

  • Restart VSCode
  • Restart My Computer
  • Run npm install (Up to date, 120 packages, version 8.5.5)
  • Run npm outside VSCode, directly on the prompt (same error)
  • Delete package-lock.json
  • Reinstall NodeJS (17.8.0)
  • Install an older version of NodeJS (17.7.1)
  • Search for node.js running in the background (there is none)
  • Disable Windows Security
  • Run npm cache clear --force

Does anyone have any idea how to solve this error?

Maybe one of the git links (https://registry.npmjs.org/nw-builder) from the nw-builder package is down/offline? In that case, is there any way around it so I can start building with nw.js?

Thank you for your help!


Solution

  • Make sure you have Git installed:

    You'll likely want to change your code to:

      "devDependencies": {
        "nw": "0.62.1-sdk"
      }
    

    The ^ can download the normal version if it was published after the sdk version.

    I haven't used nw-builder, but from my understanding, it hasn't received any updates in several years. There is a GitHub issue related to this:

    Finally, here are instructions for how to manually create your own build:

    More tutorials are at: