![](/img/trans.png)
[英]Could not find local “typescript” package.The “@ngtools/webpack” package Angular 2
[英]ng new fails with yarn : Couldn't find package “@ngtools/webpack@1.10.2”
我嘗試用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 ,但出現了兩個錯誤之一。
$ 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
刪除節點模塊文件並重新安裝Npm
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.