npm insists on using my home directory as the current working directory, no matter which directory I am executing commands from.
Happens with both cmd and Powershell, I've tried removing and reinstalling node, both using the installer on nodejs.org, and via Chocolatey with the same result.
If I navigate to e.g. C:\test
and run npm init
, the wizard places the resulting package.json
file in my home folder.
If I run npm install <package>
from any folder, the package is installed to C:\Users\myusername\node_modules
Trying to install a package globally also fails, with this
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\ProgramData\\chocolatey\\lib\\nodejs.commandline.0.10.33\\tools\\node.exe" "C:\\ProgramData\\chocolatey\\lib\\npm.1.4.9\\tools\\node_modules\\npm\\bin\\npm-cli.js" "install" "gulp" "-g"
npm ERR! cwd C:\Users\<myusername>
If I navigate to a folder, start the node REPL and run process.cwd()
the directory I started node from is returned, so the issue seems to be limited to npm.
Running npm get
gives this result:
C:\test> npm get
; cli configs
registry = "https://registry.npmjs.org/"
user-agent = "npm/1.4.9 node/v0.10.33 win32 x64"
; node bin location = C:\ProgramData\chocolatey\lib\nodejs.commandline.0.10.33\tools\node.exe
; cwd = C:\Users\<myusername>
; HOME = C:\Users\<myusername>
; 'npm config ls -l' to show all defaults.
I've searched quite a bit for a solution, and have found some similar issues, but none that solved my problem. I know that npm walks up the directory tree to look for a node_modules folder, but this happens in folders outside my home directory as well.
Any tips on what I try to resolve this?