user11860648
user11860648

Reputation:

npm install windows-build-tools prompts for admin powershell

I'm trying to install windows-build-tools using NPM. I tried it from the command prompt and it told me to use Administrative Powershell. So I opened up a PowerShell instance in admin mode (right click, 'Run as Administrator') and reran the command:

PS C:\Users\me> npm install -g windows-build-tools

The installation failed, and it says Please restart this script from an administrative PowerShell!

How can I install this npm package?

This is not a duplicate of Windows-build-tools installation failed -- that question suggests adding Powershell to the path and I already have Powershell on my path.

I have also tried with the --production flag in addition to the global flag that I had in the above example; same results.

Full output:

PS C:\Users\me> npm install -g windows-build-tools

> [email protected] postinstall C:\Users\me\AppData\Roaming\npm\node_modules\windows-build-tools
> node ./dist/index.js



Downloading python-2.7.15.amd64.msi
[>                                            ] 0.0% (0 B/s)
Downloaded python-2.7.15.amd64.msi. Saved to C:\Users\me\.windows-build-tools\python-2.7.15.amd64.msi.
Downloading vs_BuildTools.exe
[>                                            ] 0.0% (0 B/s)
Downloaded vs_BuildTools.exe. Saved to C:\Users\me\.windows-build-tools\vs_BuildTools.exe.

Starting installation...
Please restart this script from an administrative PowerShell!
The build tools cannot be installed without administrative rights.
To fix, right-click on PowerShell and run "as Administrator".
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node ./dist/index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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\me\AppData\Roaming\npm-cache\_logs\2019-07-30T20_46_40_244Z-debug.log

Relevant part of the debug log (you can see my PATH in the 4th line; Powershell is at the end):

4102 silly postinstall [email protected]
4103 info lifecycle [email protected]~postinstall: [email protected]
4104 verbose lifecycle [email protected]~postinstall: unsafe-perm in lifecycle true
4105 verbose lifecycle [email protected]~postinstall: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\me\AppData\Roaming\npm\node_modules\windows-build-tools\node_modules\.bin;C:\Users\me\AppData\Roaming\npm\node_modules\.bin;C:\windows\system32;C:\windows;C:\windows\System32\Wbem;C:\windows\System32\WindowsPowerShell\v1.0\;C:\windows\System32\OpenSSH\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files\nodejs\;C:\Users\me\AppData\Local\Programs\Python\Python37-32\Scripts\;C:\Users\me\AppData\Local\Programs\Python\Python37-32\;C:\Users\me\AppData\Local\Microsoft\WindowsApps;C:\Users\me\AppData\Local\JetBrains\IntelliJ IDEA 2019.2\bin;C:\Users\me\AppData\Local\Programs\Git\cmd;C:\Users\me\AppData\Roaming\npm;C:\windows\system32\WindowsPowerShell\v1.0
4106 verbose lifecycle [email protected]~postinstall: CWD: C:\Users\me\AppData\Roaming\npm\node_modules\windows-build-tools
4107 silly lifecycle [email protected]~postinstall: Args: [ '/d /s /c', 'node ./dist/index.js' ]
4108 silly lifecycle [email protected]~postinstall: Returned: code: 1  signal: null
4109 info lifecycle [email protected]~postinstall: Failed to exec postinstall script
4110 timing action:postinstall Completed in 143406ms
4111 verbose unlock done using C:\Users\me\AppData\Roaming\npm-cache\_locks\staging-a76b9d439c0e45ea.lock for C:\Users\me\AppData\Roaming\npm\node_modules\.staging
4112 timing stage:rollbackFailedOptional Completed in 919ms
4113 timing stage:runTopLevelLifecycles Completed in 152174ms

(Yes, I'm very sure I'm running in admin mode; the title bar of my PowerShell instance says Administrator: c:\windows\system32\windowspowershell\v1.0\powershell.exe.)

Upvotes: 11

Views: 35463

Answers (3)

Amit Khanna
Amit Khanna

Reputation: 1

I run this command "npm install --global windows-build-tools" using Administrative privileges and it worked for me.

Upvotes: 2

Thusitha Wijethunga
Thusitha Wijethunga

Reputation: 51

I am using VS2019 and this is working for me

npm install --global [email protected]

Upvotes: 4

Akinde John
Akinde John

Reputation: 1

Completely reinstall node with command

npm install reinstall -g

then retry

npm install -g windows-build-tools

Upvotes: 0

Related Questions