Search code examples
node.jsnpm-installyarnpkg

NPM and Yarn cant install anything


I tried every single Stackoverflow answer. I'm super new to Node and I installed Node v12.16.2 on my Windows 10. It had NPM v 6.14.4. When I install anything NPM showed

rollbackFailedOptional: verb npm-session c0117abdee5b38c1
npm ERR! code E404 
npm ERR! 404 Not Found - GET http://registry.npmjs.org/react

I did quite a lot fixes reading stackoverflow, I reinstalled node, but still i got no change in the error. I installed yarn using their installer. Installing anything in Yarn shows,

info There appears to be trouble with your network connection. Retrying...
error An unexpected error occurred: "https://registry.npmjs.org/react: tunneling socket could not be established, cause=Hostname/IP does not match certificate's altnames: Host: registry.npmjs.org. is not in the cert's altnames: DNS:www.google.com".

Some Stackoverflow answers say its some DNS entry being cached or something. I have no clue what to do. If nothing works, is there a way to install packages without using NPM.( like copying files from another computer )


Solution

  • I took a look at my yarn config list. It had a lot more than what it needed with many proxy entries, strict-ssl stuff and many more. I deleted everything and started adding whats needed. And now I'm able to install again. Here's my yarn config list:

    yarn config v1.22.4
    info yarn config
    {
      'version-tag-prefix': 'v',
      'version-git-tag': true,
      'version-commit-hooks': true,
      'version-git-sign': false,
      'version-git-message': 'v%s',
      'init-version': '1.0.0',
      'init-license': 'MIT',
      'save-prefix': '^',
      'bin-links': true,
      'ignore-scripts': false,
      'ignore-optional': false,
      registry: 'https://registry.yarnpkg.com',
      'strict-ssl': true,
      'user-agent': 'yarn/1.22.4 npm/? node/v12.16.2 win32 x64'
    }
    info npm config
    {
      registry: 'https://registry.npmjs.org/'
    }