From 3c37030807011ade9028e9cbc6ae5bc1802262fa Mon Sep 17 00:00:00 2001 From: zhao kang <1060401583@qq.com> Date: Wed, 16 Nov 2022 18:36:39 +0800 Subject: [PATCH] Improve Windows compatibility (#24) --- index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.js b/index.js index c5d2438..783650d 100644 --- a/index.js +++ b/index.js @@ -40,8 +40,9 @@ const getGlobalNpmrc = () => { const getDefaultNpmPrefix = () => { if (isWindows) { + const {APPDATA} = process.env; // `c:\node\node.exe` → `prefix=c:\node\` - return path.dirname(process.execPath); + return APPDATA ? path.join(APPDATA, 'npm') : path.dirname(process.execPath); } // `/usr/local/bin/node` → `prefix=/usr/local`