【问题标题】:Why can't Yarn install Angular 2's scoped packages (e.g. @angular/common)?为什么 Yarn 不能安装 Angular 2 的作用域包(例如 @angular/common)?
【发布时间】:2017-04-08 10:33:45
【问题描述】:

对于我的大部分项目,我已经成功地从 npm 迁移到 Yarn。但是我的 Angular 2 项目导致错误:

$ yarn add  "@angular/common"
yarn add v0.17.8
info No lockfile found.
[1/4] Resolving packages...
error Couldn't find package "@angular/common" on the "npm" registry.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

即使使用 Angular 提供的快速入门之一:

$ git clone https://github.com/angular/quickstart.git quickstart && cd quickstart
…
$ yarn install
yarn install v0.17.8
info No lockfile found.
[1/4] Resolving packages...
error Couldn't find package "@types/node" on the "npm" registry.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

我是否遗漏了一些明显的东西?我在任何地方都没有看到任何有此问题的帖子,所以这可能是环境问题?

$ yarn versions
yarn versions v0.17.8
{ yarn: '0.17.8',
  'angular-quickstart': '1.0.0',
  http_parser: '2.7.0',
  node: '6.9.1',
  v8: '5.1.281.84',
  uv: '1.9.1',
  zlib: '1.2.8',
  ares: '1.10.1-DEV',
  icu: '57.1',
  modules: '48',
  openssl: '1.0.2j' }
Done in 0.06s.

(我在 linux/f25 上运行)

我感觉它与作用域包名称中的 @-symbol 有关?

【问题讨论】:

  • 我无法在 Ubuntu 16.10 上使用 v0.17.8 进行复制。尝试清理 Yarn 缓存 (yarn cache clean) 并重新运行。另外,我认为其他没有作用域(带有@)的包可以正常工作吗?测试npm install @angular/common 是否可以正常工作以排除任何网络问题也可能会有所帮助。
  • npm install @angular/common 工作正常,npm install 例如快速入门。刚刚注意到上面快速入门的错误出现在 "@types/node" 上(之前出现在 @angular/forms 上)。我安装的 @ 似乎真的有问题?
  • 这看起来很奇怪。 This bug 看起来很相似 - 你在使用代理吗?
  • 无代理。我正在使用 nvm 可能会干扰。
  • 好像和github.com/yarnpkg/yarn/issues/620一样(我在那边加了评论)

标签: angular npm yarnpkg


【解决方案1】:

yarn 中似乎存在一个错误,它将带有 at 标志的 URL 视为需要身份验证的 url。然后它使用_auth 配置添加一个身份验证头。 (我有一个 `_auth' npm 配置)

以下方法暂时解决了它(在解决之前一直解决):

$ npm config delete _auth

另见https://github.com/yarnpkg/yarn/issues/2030

【讨论】:

    猜你喜欢
    • 2022-10-15
    • 2016-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-30
    相关资源
    最近更新 更多