Cannot npm install --save electron because group policy prevent CMD execution in %appdata% folder

Viewed 64

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.

0 Answers
Related