【发布时间】: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一样(我在那边加了评论)