Search code examples
npmyarnpkg

Cannot install any packages with yarn add


In my react application, I recently switched package managers from npm to yarn. I'm trying to install some redux packages but they all fail. Commands like yarn add redux and yarn add react-redux all give me errors like

yarn add v1.22.19
[1/4] 🔍  Resolving packages...
error Couldn't find package "react-redux" on the "npm" registry.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

. The output of yarn config list is

yarn config v1.22.19
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': false,
  'user-agent': 'yarn/1.22.19 npm/? node/v16.17.1 darwin arm64',
  lastUpdateCheck: 1690739349194
}

Is there anything wrong with my yarn setup?


Solution

  • The reason why yarn could not add any packages is because my npm config list had a custom repository configured. I ran the command npm config delete registry to delete the custom repository, reset the registry with yarn config set registry https://registry.npmjs.org/ , deleted the yarn cache with yarn cache clean.

    After restarting my terminal, I was able to download react-redux using yarn add react-redux.