Issue
Our group-policies does not allow to execute cmd files from the windows %appdata% folder. When I try to install electron this error happens:
npm install --save electron
npm ERR! code 1
npm ERR! path C:\data\dev\dy\we\quick-start\node_modules\electron
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c C:\Users\X\AppData\Local\Temp\postinstall-a836babe.cmd
npm ERR! Blocked by group policy. Please contact your system administrator (translated).
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\X\AppData\Local\npm-cache\_logs\2022-09-06T09_22_56_569Z-debug-0.log
Tried solution
Overrule the installation path by adding
prefix = 'C:\data\dev\npm-global'
into C:\Users\X\.npmrc file, but the error persits.
Question
Is there any possibility, to change the usage of %appdata% to a custom folder like C:\data\dev\npm-global ?
Since there is always a dynamic electron-a86xxxx.cmd file downloaded it is not possible to whitelist a specific file for the %appdata% folder.
Used Versions
Node: v16.17.0
NPM: 8.15.0
EDIT 1
npm get prefix outputs this C:\data\dev\npm-global
EDIT 2
npm config list outputs this prefix = "C:\\Users\\X\\AppData\\Roaming\\npm" ; overridden by user
EDIT 3
Found another .npmrc config file in C:\Program Files\nodejs\node_modules\npm and updated it as well.
EDIT 4
Executing npm install -g electron results in the same error. NPM always wants to run a CMD file from the %appdata% folder.
EDIT 5
It seems like the command npm install -g electron did work and does put the files into the C:\data\dev\npm-global folder. But electron still wants to execute the cmd file from the appdata folder.
EDIT 6
The issue seems to be with the postinstall-xxxxxxx.cmd which seems to be electron specific. I already installed NodeJS into C:\data\dev\NodeJS but the electron installation still wants to execute a cmd from the appfolder.
I ran into the same problem you're having with npm 8.15.0, albeit with a different package. I upgraded to the latest non-LTS release, which at the time of this writing is node 18.10.0 and npm 8.19.2, and the issue went away.
I do have the following set in
.npmrc. I don't know if they made a difference (it still failed with npm 8.15.0), as I haven't tried without them there. I do know npm states it ignores the tmp config value, so it may not be needed.