我有一个新项目,但是执行 ng serve 时出现错误
Posted
技术标签:
【中文标题】我有一个新项目,但是执行 ng serve 时出现错误【英文标题】:I have a new project, but when execute ng serve, I get error 【发布时间】:2019-03-07 13:20:20 【问题描述】:我需要更改此主题,我无法发布新主题。 我已经更新了脚本,并安装了新包。 我仍然收到错误,但不是我上次发布的错误。
_ _ _
__ _ _ __ __ _ _ _ | | __ _ _ __ ___ | |(_)
/ _` || '_ \ / _` || | | || | / _` || '__|_____ / __|| || |
| (_| || | | || (_| || |_| || || (_| || | |_____|| (__ | || |
\__,_||_| |_| \__, | \__,_||_| \__,_||_| \___||_||_|
|___/
angular-cli: 1.0.0-beta.26
node: 8.12.0
os: linux x64
@angular/animations: 6.1.9
@angular/cdk: 6.4.7
@angular/common: 6.1.9
@angular/compiler: 6.1.9
@angular/core: 6.1.9
@angular/forms: 6.1.9
@angular/http: 6.1.9
@angular/material: 2.0.0-beta.10
@angular/platform-browser: 6.1.9
@angular/platform-browser-dynamic: 6.1.9
@angular/platform-server: 6.1.9
@angular/router: 6.1.9
@angular/compiler-cli: 6.1.9
@ngtools/webpack: 1.10.2
我现在收到此错误。这是我现在不知道如何修复的新错误。
WARNING in ./~/ng2-webstorage/dist/app.js
11:35-46 "export 'OpaqueToken' was not found in '@angular/core'
WARNING in ./~/@angular/material/@angular/material.es5.js
6128:45-70 "export 'ConnectedOverlayDirective' was not found in '@angular/cdk/overlay'
WARNING in ./~/@angular/material/@angular/material.es5.js
13725:44-56 "export 'OverlayState' was not found in '@angular/cdk/overlay'
WARNING in ./~/@angular/material/@angular/material.es5.js
15765:42-54 "export 'OverlayState' was not found in '@angular/cdk/overlay'
WARNING in ./~/@angular/material/@angular/material.es5.js
16831:48-60 "export 'OverlayState' was not found in '@angular/cdk/overlay'
WARNING in ./~/@angular/material/@angular/material.es5.js
17553:48-60 "export 'OverlayState' was not found in '@angular/cdk/overlay'
WARNING in ./~/@angular/material/@angular/material.es5.js
18421:48-60 "export 'OverlayState' was not found in '@angular/cdk/overlay'
WARNING in ./~/@angular/material/@angular/material.es5.js
19726:48-60 "export 'OverlayState' was not found in '@angular/cdk/overlay'
WARNING in ./~/angular2-semantic-ui/components/dropdown/dropdown.ts
139:16-23 "export 'trigger' was not found in '@angular/core'
WARNING in ./~/angular2-semantic-ui/components/dropdown/dropdown.ts
140:20-25 "export 'state' was not found in '@angular/core'
WARNING in ./~/angular2-semantic-ui/components/dropdown/dropdown.ts
140:38-43 "export 'style' was not found in '@angular/core'
WARNING in ./~/angular2-semantic-ui/components/dropdown/dropdown.ts
144:20-25 "export 'state' was not found in '@angular/core'
WARNING in ./~/angular2-semantic-ui/components/dropdown/dropdown.ts
144:36-41 "export 'style' was not found in '@angular/core'
WARNING in ./~/angular2-semantic-ui/components/dropdown/dropdown.ts
148:20-30 "export 'transition' was not found in '@angular/core'
WARNING in ./~/angular2-semantic-ui/components/dropdown/dropdown.ts
148:54-61 "export 'animate' was not found in '@angular/core'
WARNING in ./~/angular2-semantic-ui/components/accordion/accordion_panel.ts
53:16-23 "export 'trigger' was not found in '@angular/core'
WARNING in ./~/angular2-semantic-ui/components/accordion/accordion_panel.ts
54:20-25 "export 'state' was not found in '@angular/core'
WARNING in ./~/angular2-semantic-ui/components/accordion/accordion_panel.ts
54:38-43 "export 'style' was not found in '@angular/core'
WARNING in ./~/angular2-semantic-ui/components/accordion/accordion_panel.ts
59:20-25 "export 'state' was not found in '@angular/core'
WARNING in ./~/angular2-semantic-ui/components/accordion/accordion_panel.ts
59:36-41 "export 'style' was not found in '@angular/core'
WARNING in ./~/angular2-semantic-ui/components/accordion/accordion_panel.ts
64:20-30 "export 'transition' was not found in '@angular/core'
WARNING in ./~/angular2-semantic-ui/components/accordion/accordion_panel.ts
64:53-60 "export 'animate' was not found in '@angular/core'
WARNING in ./~/angular2-semantic-ui/components/accordion/accordion_panel.ts
65:20-30 "export 'transition' was not found in '@angular/core'
WARNING in ./~/angular2-semantic-ui/components/accordion/accordion_panel.ts
65:53-60 "export 'animate' was not found in '@angular/core'
我找不到这个错误的答案。我希望,我现在能找到答案,所以我可以继续写这个脚本。
【问题讨论】:
您可以尝试npm i
并再试一次吗?看来你反正不在rigth文件夹中
确实用 npm i 再试一次,但结果是同样的错误...
【参考方案1】:
我建议阅读以下内容:
https://www.techiediaries.com/updating-angular-cli-projects/
在此页面上声明:
Angular 6 使用 angular.json 而不是 angular-cli.json。 这可以通过以下方式实现:
ng update @angular/cli
这解决了我的问题。
祝你好运
【讨论】:
我已尝试使用 ng update @angular/cli,现在我收到此错误:此版本的 CLI 仅与 Angular 5.0.0 或更高版本兼容。请访问下面的链接以查找有关如何更新 Angular 的说明。 你需要运行 npm install --save-dev @angular/cli@latest @Niklas 我也试过这个并且得到这个错误Cannot destructure property createHash of 'undefined' or 'null'
【参考方案2】:
Angular 6 寻找 angular.json 而不是 angular-cli.json。
您需要更新您的@angular/cli
。添加到上面的答案
我确实使用以下命令更新了所有包并更新了所有依赖项。以消除与其他软件包的所有兼容性问题。
如果您要启动应用程序或演示应用程序,请按照此过程操作。如果您为生产应用执行此操作,请格外小心。
npm install -g npm-check-updates
ncu -u
ng update @angular/cli
npm install
安装 npm-check-updates
npm install -g npm-check-updates
使用 ncu 更新你的 package.json
ncu
用于显示
ncu -u
重写你的 package.json
更新您的 @angular/cli 以修改您的应用程序以与 Angular 6 兼容
ng update @angular/cli
然后运行 npm install
来更新你的包
【讨论】:
【参考方案3】:重新安装@angular/cli
npm install @angular/cli
【讨论】:
【参考方案4】:只需使用官方升级指南,它会告诉您需要做什么以满足您自己的特殊需求:
https://update.angular.io/
【讨论】:
【参考方案5】:这似乎是由于安装了不同版本的 angular-cli 造成的。 我刚刚创建了一个新项目,使用 new 命令,然后复制到 src 目录。然后全部编译成功。
ng new UX7
【讨论】:
【参考方案6】:在我的情况下,我只需要在删除/重新克隆一个 repo 后关闭/重新打开我的终端。不知道那里发生了什么。
【讨论】:
以上是关于我有一个新项目,但是执行 ng serve 时出现错误的主要内容,如果未能解决你的问题,请参考以下文章
仅当 ng serve --prod 时出现 AngularFire 错误
在angular2应用程序中运行ng serve时出现错误'无法读取未定义的属性'长度''
使用 vue/cli 运行 npm run serve 时出现问题