I’m working on setting up my development environment for a mobile app project and running into issues with npm package installation. When I try to install packages globally, I get this frustrating error that stops the installation process.
My setup:
Windows 10 system
Node.js version 10.15.3
npm version 6.4.1
No corporate proxy setup
Already cleared http/https environment variables
When I run the installation command, here’s what happens:
C:\>npm install -g expo-cli
npm ERR! Cannot read property 'startsWith' of null
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\myuser\AppData\Roaming\npm-cache\_logs\2019-04-15T10_25_14_582Z-debug.log
I’ve checked my npm configuration and everything seems normal:
C:\>npm config get registry
https://registry.npmjs.org/
C:\>npm config get proxy
null
C:\>npm config get https-proxy
null
The debug log shows the error originates from the make-fetch-happen module when it tries to process proxy settings, even though I don’t have any proxy configured. The stack trace points to agent.js line 164 where it’s trying to call startsWith on a null value.
I just want to install the CLI tools so I can start building my project. Has anyone encountered this before and found a working solution?
Had this exact problem two years ago on Windows. Turned out it wasn’t the cache - corrupted npm config files were the culprit. I deleted the .npmrc file in my user directory (C:\Users[username].npmrc) and let npm recreate it with defaults. Also check your system environment variables for old proxy configs - Windows loves hanging onto those even when you think they’re gone. Delete the .npmrc file first, then try your global install again. Still broken? Try nvm-windows to get a fresh Node/npm setup without nuking your current install.
This happens when npm tries to parse environment variables with null values, usually proxy settings. Even if your npm config shows null proxies, Windows environment variables might still mess things up. Open Command Prompt as admin and run set | findstr proxy to check for leftover proxy variables. If you see HTTP_PROXY, HTTPS_PROXY, or NO_PROXY set to empty or null, clear them with set HTTP_PROXY= and set HTTPS_PROXY=. Restart your command prompt and try installing again. The make-fetch-happen module should stop throwing that startsWith error once it has clean environment variables.