"@ angular/compiler-cli"软件包未正确安装

Jan*_*sen 6 angular-cli angular

使用Angular CLI 1.0(来自beta.31)将我的项目升级到Angular 4.0(从2.4),按照迁移指南后我得到以下错误:

> ng build --prod

The "@angular/compiler-cli" package was not properly installed.
Error: The "@angular/compiler-cli" package was not properly installed.
    at Object.<anonymous> (/home/jan/src/fm-repos/fm-ui/node_modules/@ngtools/webpack/src/index.js:14:11)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/jan/src/fm-repos/fm-ui/node_modules/@angular/cli/tasks/eject.js:10:19)
    at Module._compile (module.js:571:32)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:488:32)
    at tryModuleLoad (module.js:447:12)
    at Function.Module._load (module.js:439:3)
    at Module.require (module.js:498:17)
    at require (internal/module.js:20:19)
Run Code Online (Sandbox Code Playgroud)

迁移后我的角度依赖关系:

"@angular/animations": "^4.0.0",
"@angular/common": "^4.0.0",
"@angular/compiler": "^4.0.0",
"@angular/compiler-cli": "^4.0.0",
"@angular/core": "^4.0.0",
"@angular/forms": "^4.0.0",
"@angular/http": "^4.0.0",
"@angular/platform-browser": "^4.0.0",
"@angular/platform-browser-dynamic": "^4.0.0",
"@angular/router": "^4.0.0",
"@angular/cli": "1.0.0",
"@angular/material": "2.0.0-beta.3",
Run Code Online (Sandbox Code Playgroud)

注意:这个类似的问题是关于Angular 2项目:Angular2 CLI错误"@ angular/compiler-cli"包未正确安装

Jan*_*sen 9

确保你有打字稿2.2在你package.json并确保您的tsconfig正常更新.

细节:

安装Angular CLI 1.0后,创建一个新的虚拟项目:

ng new dummy
Run Code Online (Sandbox Code Playgroud)

然后删除node_modules目录:

rm -rf ./dummy/node_modules
rm -rf ./myproject/node_modules
Run Code Online (Sandbox Code Playgroud)

以及项目和项目diff之间的变化dummy:

diff -bur ./dummy/ ./myproject/
Run Code Online (Sandbox Code Playgroud)

在许多变化中,为我解决这个错误所需的关键变化是TypeScript和tsconfig更改:

package.json:

"typescript": "~2.0.3" ==> "typescript": "~2.2.0"
Run Code Online (Sandbox Code Playgroud)

.angular-cli.json

更改:

"tsconfig": "tsconfig.json"
Run Code Online (Sandbox Code Playgroud)

至:

"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
Run Code Online (Sandbox Code Playgroud)

并从dummy项目中添加这些新文件,并安装您的包:

npm install
Run Code Online (Sandbox Code Playgroud)


小智 8

我在Linux机器_ _ ____ _ _ /\_ __ __ _ _ _ |创建新的全新安装 | __ _ _ __ /| | | | /△\ | '\/ _ | | | | |/ _| ' | | | | | | | /\ | | | | ( | | | | | | | | | | | | | | | |/| __ | | | __,| __,| | __,| | ____ | _____ | | |/@ angular/cli:1.0.1节点:6.10.2 os:linux x64

我正在使用创建新的角度2项目

新的angularhellword

项目成功创建但是当我执行命令时

服务

鉴于我上面同样的错误

"@ angular/compiler-cli"软件包未正确安装.

请采取以下步骤以避免问题:

"npm uninstall --save-dev angular-cli"

"npm install --save-dev @ angular/cli @ latest"

它适用于我,项目运行成功.