3

I want to install Windows build tools with an elevated PowerShell console using this command:

npm install --global --production windows-build-tools

but I'm getting the following error back everytime I run the the npm install command above:

windows-build-tools@5.2.2 postinstall C:\Users\AKA\AppData\Roaming\npm\node_modules\windows-build-tools> node ./dist/index.js

C:\Users\AKA\AppData\Roaming\npm\node_modules\windows-build-tools\node_modules\in-gfw\lib\os.js:53
                        throw resultError;
                        ^

Error: spawnSync powershell.exe ENOENT
    at Object.spawnSync (internal/child_process.js:1002:20)
    at Object.spawnSync (child_process.js:614:24)
    at spawnSync (C:\Users\AKA\AppData\Roaming\npm\node_modules\windows-build-tools\node_modules\in-gfw\lib\geo.js:67:36)
    at Object.queryRegFromPowershell (C:\Users\AKA\AppData\Roaming\npm\node_modules\windows-build-tools\node_modules\in-gfw\lib\geo.js:73:3)
    at loop (C:\Users\AKA\AppData\Roaming\npm\node_modules\windows-build-tools\node_modules\in-gfw\lib\geo.js:113:16)
    at opts.shift (C:\Users\AKA\AppData\Roaming\npm\node_modules\windows-build-tools\node_modules\in-gfw\lib\geo.js:116:7)
    at spawn (C:\Users\AKA\AppData\Roaming\npm\node_modules\windows-build-tools\node_modules\in-gfw\lib\geo.js:100:5)
    at spawnSync (C:\Users\AKA\AppData\Roaming\npm\node_modules\windows-build-tools\node_modules\in-gfw\lib\geo.js:68:2)
    at Object.queryRegFromRegExe (C:\Users\AKA\AppData\Roaming\npm\node_modules\windows-build-tools\node_modules\in-gfw\lib\geo.js:96:3)
    at loop (C:\Users\AKA\AppData\Roaming\npm\node_modules\windows-build-tools\node_modules\in-gfw\lib\geo.js:113:16)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! windows-build-tools@5.2.2 postinstall: `node ./dist/index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the windows-build-tools@5.2.2 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional
         logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\AKA\AppData\Roaming\npm-cache\_logs\2019-09-02T01_30_08_978Z-debug.log
PS> node -v
10.16.0
PS> npm -v 
6.9.0
Ansgar Wiechers
  • 193,178
  • 25
  • 254
  • 328
Hendrx
  • 69
  • 2
  • 3
  • 10
  • For help with your code: *show* your code. Show the content of `2019-09-02T01_30_08_978Z-debug.log` too. – Ansgar Wiechers Sep 02 '19 at 08:58
  • Ansgar wiechers thanks for offering help but pls the content of 2019-09-02T01_30_08_978Z-debug.log is over 4thousand lines of error how do i go about posting it pls – Hendrx Sep 02 '19 at 09:20

4 Answers4

13

Add %SystemRoot%/system32/WindowsPowerShell/v1.0 to your PATH Variable,

  1. cmd+q and search env and hit enter
  2. click environment variables in the advanced tab
  3. find Path/PATH variable and click edit
  4. Click new and paste %SystemRoot%/system32/WindowsPowerShell/v1.0
  5. click ok and restart your terminal and try installing again
rushwe11
  • 131
  • 1
  • 3
0

This happened with me when I was using my old react project. This was due to the old libraries in my case. You can create a new react app using create-react-app and replace the new src folder with previous src folder of react project and install the dependencies(if any).

Sahil Rajpal
  • 510
  • 4
  • 8
0

download powershell.exe file online or just copy and paste this file in C:\Windows\System32\WindowsPowerShell\v1.0

https://www.exefiles.com/en/exe/powershell-exe/ - To download powershell.exe file online

if there is no powershell.exe in this folder C:\Windows\System32\WindowsPowerShell\v1.0 download the file from the site mentioned above and place in the folder then close all terminals and restart the terminal and try again

Rahul Somaraj
  • 251
  • 2
  • 9
0

Add C:\Windows\System32\WindowsPowerShell\v1.0 to your PATH Variable,

cmd+q and search env and hit enter click environment variables in the advanced tab find Path/PATH variable and click edit Click new and paste C:\Windows\System32\WindowsPowerShell\v1.0 click ok and restart your terminal and try installing again

mani
  • 1