npm install windows-build-tools prompts for admin powershell - npm-install

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
> windows-build-tools#5.2.2 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! 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\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 windows-build-tools#5.2.2
4103 info lifecycle windows-build-tools#5.2.2~postinstall: windows-build-tools#5.2.2
4104 verbose lifecycle windows-build-tools#5.2.2~postinstall: unsafe-perm in lifecycle true
4105 verbose lifecycle windows-build-tools#5.2.2~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 windows-build-tools#5.2.2~postinstall: CWD: C:\Users\me\AppData\Roaming\npm\node_modules\windows-build-tools
4107 silly lifecycle windows-build-tools#5.2.2~postinstall: Args: [ '/d /s /c', 'node ./dist/index.js' ]
4108 silly lifecycle windows-build-tools#5.2.2~postinstall: Returned: code: 1 signal: null
4109 info lifecycle windows-build-tools#5.2.2~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
Node version: 10.16.0
NPM version: 6.9.0
(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.)

I am using VS2019 and this is working for me
npm install --global windows-build-tools#4.0.0

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

Completely reinstall node with command
npm install reinstall -g
then retry
npm install -g windows-build-tools

Related

'npm start' kicks off loop to install expo-cli

QUESTION: How can I make it so $ echo $PATH returns export PATH=~/.npm-global/bin:$PATH
BACKSTORY:
I did an npm install on terminal (macOS Catalina) and started
to get into a loop about installing expo cli when trying to npm
start. I've since followed instructions here:
https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally
had to execute step 5 (from link above) as source ~/.bash_profile
Tried npm start but still running into the loop
Already have npm 6.13.4 installed. However, running npm start results in below. Notice how it says Expo CLI installed but asked to install globally again so the 2nd time I say n:
(base) MacBook-Pro:rn-starter user$ npm start
> # start /Users/user/Desktop/REACT NATIVE/rn-starter
> expo start
This command requires Expo CLI.
Do you want to install it globally [Y/n]? Y
Installing the package 'expo-cli'...
Expo CLI installed. You can run `expo --help` for instructions.
This command requires Expo CLI.
Do you want to install it globally [Y/n]? n
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! # start: `expo start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the # start 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! /Users/user/.npm/_logs/2020-04-03T14_39_24_884Z-debug.log
Here's what's on line 8 of the log file:
8 verbose lifecycle #~start: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/user/Desktop/REACT NATIVE/rn-starter/node_modules/.bin:/opt/anaconda3/bin:/opt/anaconda3/condabin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/usr/local/git/bin
I've previously installed Anaconda (several months back) and have uninstalled it using https://docs.anaconda.com/anaconda/install/uninstall/ However, running $ echo $PATH results in
/opt/anaconda3/bin:/opt/anaconda3/condabin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/usr/local/git/bin
QUESTION: How can I make it so $ echo $PATH returns export PATH=~/.npm-global/bin:$PATH
Appreciate any suggestions that can help!
How is your package.json file?
Your npm start must is calling the expo

Failed to install puppeteer using npm - connect EACCES

When I try to run a npm install, it fails at a dependency called puppeteer.
And if I run:
npm install -g puppeteer#1.5.0
(existing in package.json as "puppeteer": "1.5.0",) it fails with the following error:
npm ERR! code EACCES
npm ERR! errno EACCES
npm ERR! FetchError: request to http://registry.npmjs.org/puppeteer failed, reason: connect EACCES 104.16.27.35:80
npm ERR! at ClientRequest.req.on.err (C:\Program Files\nodejs\node_modules\npm\node_modules\node-fetch-npm\src\index.js:68:14)
npm ERR! at ClientRequest.emit (events.js:182:13)
npm ERR! at Socket.socketErrorListener (_http_client.js:391:9)
npm ERR! at Socket.emit (events.js:182:13)
npm ERR! at emitErrorNT (internal/streams/destroy.js:82:8)
npm ERR! at emitErrorAndCloseNT (internal/streams/destroy.js:50:3)
npm ERR! at process._tickCallback (internal/process/next_tick.js:63:19)
but I can access that URL (http://registry.npmjs.org/puppeteer) using my browser.
The other dependencies specified in package.json work fine. Only this one generates problems.
Details:
npm - 6.2.0
node - v10.9.0
OS: Windows
Any suggestions?
npm ERR! code EACCES
npm ERR! errno EACCES
This is a permission error, on a normal day, I will say you should just use sudo npm install -g puppeteer#1.5.0, but I will suggest you reclaim ownership of the .npm directory by running this:
sudo chown -R $(whoami) ~/.npm
Then you need the write permission in node_modules directory:
sudo chown -R $(whoami) /usr/lib/node_modules
after which you can run your npm install -g puppeteer#1.5.0, This should solve your issue.
UPDATE:
I will suggest two other options for you,
from your terminal, run this:
npm config set unsafe-perm=true
OR
use yarn add for your installation.
also sometimes it just takes a while; I used npm install (I'm trying to use formkit but I'm not sure if it matters) --verbose and I'm getting a bunch of
npm http fetch GET 200 https://registry.npmjs.org/#formkit%2fvalidation
70085ms (cache stale)
so I assume its some issue that requires me to download things that take a very long time. Maybe an issue connecting to the verification server?
Edit: restarted computer, cleared cache, etc etc. Still weird and slow.
Not sure what happened but fixed it by going into my IDE (Jetbrains WebStorm) and changing my package handler in settings to a different nodejs. The one I was using was in Program Files and was having trouble accessing pieces in AppData/Roaming, There was another installation inside AppData and picking that one automatically solved my permissions issue.

Unhandled 'error' event when run npm install

When I run mvnw -Pdev,webpack command, I got this error. I will appreciate if anyone could help me.
--- frontend-maven-plugin:1.6:npm (npm install) # demoapp ---
Running 'npm install' in C:\Users\pc\demoapp
> demoapp#0.0.0 postinstall C:\Users\pc\demoapp
> webdriver-manager update --gecko false
[09:55:46] I/config_source - curl -oC:\Users\pc\demoapp\node_modules\protractor\node_modules\webdriver-manager\selenium\standalone-response.xml https://selenium-release.storage.googleapis.com/
[09:55:46] I/config_source - curl -oC:\Users\pc\demoapp\node_modules\protractor\node_modules\webdriver-manager\selenium\chrome-response.xml https://chromedriver.storage.googleapis.com/
events.js:183
throw er; // Unhandled 'error' event
^
Error: read ECONNRESET
at TLSWrap.onread (net.js:622:25)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! demoapp#0.0.0 postinstall: `webdriver-manager update --gecko false`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the demoapp#0.0.0 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\pc\AppData\Roaming\npm-cache\_logs\2018-10-16T06_55_48_437Z-debug.log
I ran into the same symptoms because of an inconsistent node_modules/ state.
Deleting node_modules/ and running npm install --verbose solved my issue. Even despite the --verbose flags, the installation process may not show progress for four and more minutes. Checking for a changing directory size of node_modules/ regularly calmed me down and let me know the installation kept going on.
When using Windows 10 Powershell, the solution to this for me was to run Powershell as Administrator.
Prior to that, I tried deleting nodes_modules/ as described in https://stackoverflow.com/a/53558340/1207532 but that didn't make any difference for me.

npm start command with webpack on Windows 10 fails

I am currently using node to build a website. I have run the webpack dev server fine in ubuntu but in windows i cant seem to get the npm start command to work
I am able to npm run build-sw on both platforms without error but just not able to run.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! site#1.0.0 start: `npm run build-sw && ./node_modules/.bin/webpack-dev-server --progress --host 0.0.0.0 --no-info --watch-poll`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the site#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
This
I finally was able to get the project running using YARN.
It needed no configuration change.
I had to install Visual C++ but after that
yarn and yarn run start did the trick.
So on ubuntu I use npm but on windows i use yarn. Works now

Gitlab-ci-multi-runner continues if npm publish fails

I use gitlab-ci-multi-runner to publish our artifact to our own npm registry. This is the .gitlab-ci.yml file:
publish-continuous:
type: publish
script:
- npm install
- npm run test
- npm run build
- npm publish --registry $env:NPM_REGISTRY_URL
Sometimes the npm publish fails. This is the output:
$ npm publish --registry $env:NPM_REGISTRY_URL
npm ERR! Windows_NT 6.3.9600
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\SomeUser\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "publish" "--registry" "https://ourownregistry"
npm ERR! node v4.2.6
npm ERR! npm v3.6.0
npm ERR! code ENEEDAUTH
I would expect that the gitlab-ci-multi-runner stops because the job fails. But it doesn't! It reports Build succeeded.
Anyone knows how I can make the build fail if npm publish fails?
Fixed it by updating to the latest NPM. v3.8.1 fixed the issue. Now it returns a -1 exit code and the build fails.