【发布时间】:2018-03-17 11:03:55
【问题描述】:
我尝试使用 ng-cli 和 yarn 创建一个新的 Angular 项目,但找不到包 @ngtools/webpack。
我在 github 上创建了一个问题:https://github.com/angular/angular-cli/issues/9992
这是命令的结果:
$ ng set --global packageManager=yarn
$ ng new angular5-toh
create angular5-toh/README.md (1027 bytes)
create angular5-toh/.angular-cli.json (1247 bytes)
create angular5-toh/.editorconfig (245 bytes)
create angular5-toh/.gitignore (544 bytes)
create angular5-toh/src/assets/.gitkeep (0 bytes)
create angular5-toh/src/environments/environment.prod.ts (51 bytes)
create angular5-toh/src/environments/environment.ts (387 bytes)
create angular5-toh/src/favicon.ico (5430 bytes)
create angular5-toh/src/index.html (298 bytes)
create angular5-toh/src/main.ts (370 bytes)
create angular5-toh/src/polyfills.ts (3114 bytes)
create angular5-toh/src/styles.css (80 bytes)
create angular5-toh/src/test.ts (642 bytes)
create angular5-toh/src/tsconfig.app.json (211 bytes)
create angular5-toh/src/tsconfig.spec.json (283 bytes)
create angular5-toh/src/typings.d.ts (104 bytes)
create angular5-toh/e2e/app.e2e-spec.ts (294 bytes)
create angular5-toh/e2e/app.po.ts (208 bytes)
create angular5-toh/e2e/tsconfig.e2e.json (235 bytes)
create angular5-toh/karma.conf.js (923 bytes)
create angular5-toh/package.json (1297 bytes)
create angular5-toh/protractor.conf.js (722 bytes)
create angular5-toh/tsconfig.json (363 bytes)
create angular5-toh/tslint.json (3012 bytes)
create angular5-toh/src/app/app.module.ts (316 bytes)
create angular5-toh/src/app/app.component.css (0 bytes)
create angular5-toh/src/app/app.component.html (1141 bytes)
create angular5-toh/src/app/app.component.spec.ts (986 bytes)
create angular5-toh/src/app/app.component.ts (207 bytes)
error An unexpected error occurred: "Couldn't find package \"@ngtools/webpack@1.10.2\" required by \"@angular/cli@~1.7.3\" on the \"npm\" registry.".
Error: Package install failed, see above.
Package install failed, see above.
但是包在这里可用:https://www.npmjs.com/package/@ngtools/webpack
然后,我在目录中再次尝试,但再次失败并出现另一个错误
$ cd angular5-toh
$ yarn
yarn install v1.5.1
info No lockfile found.
[1/4] Resolving packages...
error An unexpected error occurred: "Couldn't find package \"@schematics/angular@0.3.2\" required by \"@angular/cli@~1.7.3\" on the \"npm\" registry.".
info If you think this is a bug, please open a bug report with the information provided in "/home/.../angular5-toh/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
那么问题出在哪里?我该如何解决这个问题?
我正在研究 Archlinux,这里是版本:
$ ng version
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
Angular CLI: 1.7.3
Node: 9.8.0
OS: linux x64
Angular:
...
$ yarn --version
1.5.1
谢谢
更新 #1 :我进行了新的尝试,但错误有所不同。
$ ng new angular5-toh
create angular5-toh/README.md (1027 bytes)
create angular5-toh/.angular-cli.json (1247 bytes)
[...]
create angular5-toh/src/app/app.component.ts (207 bytes)
error An unexpected error occurred: "Couldn't find package \"@schematics/angular@0.3.2\" required by \"@angular/cli@~1.7.3\" on the \"npm\" registry.".
Error: Couldn't find package "@schematics/package-update@0.3.2" required by "@angular/cli@~1.7.3" on the "npm" registry.
at new MessageError (/usr/lib/node_modules/yarn/lib/cli.js:186:110)
at PackageRequest.<anonymous> (/usr/lib/node_modules/yarn/lib/cli.js:36274:17)
at Generator.throw (<anonymous>)
at step (/usr/lib/node_modules/yarn/lib/cli.js:98:30)
at /usr/lib/node_modules/yarn/lib/cli.js:111:13
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:118:7)
Error: Package install failed, see above.
Package install failed, see above.
更新 #2:我尝试多次yarn install,但我得到了这两个错误之一。
$ yarn install
yarn install v1.5.1
info No lockfile found.
[1/4] Resolving packages...
error An unexpected error occurred: "Couldn't find package \"@ngtools/webpack@1.10.2\" required by \"@angular/cli@~1.7.3\" on the \"npm\" registry.".
info If you think this is a bug, please open a bug report with the information provided in "/home/.../angular5-toh/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
$ yarn install
yarn install v1.5.1
info No lockfile found.
[1/4] Resolving packages...
error An unexpected error occurred: "Couldn't find package \"@schematics/angular@0.3.2\" required by \"@angular/cli@~1.7.3\" on the \"npm\" registry.".
info If you think this is a bug, please open a bug report with the information provided in "/home/.../angular5-toh/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
当然没有 node_modules/ 目录
$ ls -l
total 28
drwxr-xr-x 1 fs fs 82 Mar 17 12:06 e2e
-rw-r--r-- 1 fs fs 923 Mar 17 12:06 karma.conf.js
-rw-r--r-- 1 fs fs 1297 Mar 17 12:06 package.json
-rw-r--r-- 1 fs fs 722 Mar 17 12:06 protractor.conf.js
-rw-r--r-- 1 fs fs 1027 Mar 17 12:06 README.md
drwxr-xr-x 1 fs fs 250 Mar 17 12:06 src
-rw-r--r-- 1 fs fs 363 Mar 17 12:06 tsconfig.json
-rw-r--r-- 1 fs fs 3012 Mar 17 12:06 tslint.json
-rw-r--r-- 1 fs fs 2321 Mar 17 12:22 yarn-error.log
【问题讨论】:
-
你检查过 Angular CLI 的问题,看看其他人是否有这个问题?在那里提出问题? SO 无法真正帮助解决任意第三方依赖项。