Angular7、创建和运行新建项目失败
Angular 7, Creating and running new project fails
我正在按照 Angular 站点上提到的所有说明进行安装和 运行 使用 Angular 7 的新项目,但是它给了我以下错误,我尝试了很多删除缓存的技巧删除整个节点模块和 npm 但没有任何效果,我需要帮助,请查看我从昨天开始不断收到的以下错误。
第一步:安装成功Angular7
C:\Users\me>npm install -g @angular/cli
C:\Users\me\AppData\Roaming\npm\ng ->
C:\Users\me\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4
(node_modules\@angular\cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for
fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current:
{"os":"win32","arch":"x64"})
+ @angular/cli@7.1.3
updated 1 package in 23.447s
第 2 步:切换文件夹并创建 my-app(但在创建 my-app 时出错,见下文)
C:\wamp\www>ng new my-app
? Would you like to add Angular routing? No
? Which stylesheet format would you like to use? CSS
CREATE my-app/angular.json (3768 bytes)
CREATE my-app/package.json (1305 bytes)
CREATE my-app/README.md (1022 bytes)
CREATE my-app/tsconfig.json (435 bytes)
CREATE my-app/tslint.json (2824 bytes)
CREATE my-app/.editorconfig (246 bytes)
CREATE my-app/.gitignore (576 bytes)
CREATE my-app/src/favicon.ico (5430 bytes)
CREATE my-app/src/index.html (292 bytes)
CREATE my-app/src/main.ts (372 bytes)
CREATE my-app/src/polyfills.ts (3694 bytes)
CREATE my-app/src/test.ts (642 bytes)
CREATE my-app/src/styles.css (80 bytes)
CREATE my-app/src/browserslist (388 bytes)
CREATE my-app/src/karma.conf.js (980 bytes)
CREATE my-app/src/tsconfig.app.json (166 bytes)
CREATE my-app/src/tsconfig.spec.json (256 bytes)
CREATE my-app/src/tslint.json (314 bytes)
CREATE my-app/src/assets/.gitkeep (0 bytes)
CREATE my-app/src/environments/environment.prod.ts (51 bytes)
CREATE my-app/src/environments/environment.ts (662 bytes)
CREATE my-app/src/app/app.module.ts (314 bytes)
CREATE my-app/src/app/app.component.html (1120 bytes)
CREATE my-app/src/app/app.component.spec.ts (978 bytes)
CREATE my-app/src/app/app.component.ts (210 bytes)
CREATE my-app/src/app/app.component.css (0 bytes)
CREATE my-app/e2e/protractor.conf.js (752 bytes)
CREATE my-app/e2e/tsconfig.e2e.json (213 bytes)
CREATE my-app/e2e/src/app.e2e-spec.ts (298 bytes)
CREATE my-app/e2e/src/app.po.ts (204 bytes)
npm WARN deprecated circular-json@0.5.9: CircularJSON is in maintenance
only, flatted is its successor.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: source-map@^0.4.2
(node_modules\scss-tokenizer\node_modules\source-map):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: zlib: unexpected end of file
npm ERR! code Z_BUF_ERROR
npm ERR! errno -5
npm ERR! zlib: unexpected end of file
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\me\AppData\Roaming\npm-cache\_logs18-12-
14T04_43_19_244Z-debug.log
Package install failed, see above.
第三步:然后我切换到my-app
C:\wamp\www>cd my-app
第 4 步:启动服务器,但这里也出现故障
C:\wamp\www\my-app>ng serve --open
Could not find module "@angular-devkit/build-angular" from
"C:\wamp\www\my-app".
Error: Could not find module "@angular-devkit/build-angular" from
"C:\wamp\www\my-app".
at Object.resolve (C:\Users\me\AppData\Roaming\npm\node_modules
\@angular\cli\node_modules\ @angular-devkit\core\node\resolve.js:141:11)
at Observable.rxjs_1.Observable [as _subscribe]
(C:\Users\me\AppData\Roaming\npm\node_modules
\@angular\cli\node_modules\@angular-devkit\architect\src\
architect.js:132:40)
at Observable._trySubscribe
(C:\Users\me\AppData\Roaming\npm\node_modules
\@angular\cli\node_modules\rxjs\internal\ Observable.js:44:25)
at Observable.subscribe
(C:\Users\me\AppData\Roaming\npm\node_modules
\@angular\cli\node_modules\rxjs\internal\Observable.js:30:22)
at
C:\Users\me\AppData\Roaming\npm\node_modules
\@angular\cli\node_modules\rxjs\internal\Observable.js:99:19
at new Promise (<anonymous>)
at Observable.toPromise
(C:\Users\me\AppData\Roaming\npm\node_modules
\@angular\cli\node_modules\rxjs\internal\Observable.js:97:16)
at ServeCommand.initialize
(C:\Users\me\AppData\Roaming\npm\node_modules
\@angular\cli\models\architect-command.js:88:94)
at process._tickCallback (internal/process/next_tick.js:43:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:779:11)
C:\wamp\www\my-app>
请给我一些建议,谢谢
delete the node_modules:
rm -rf node_modules
并删除了软件包-lock.json、
then re-install:
npm install
It works for me.
好的,我终于找到了解决方案!
我刚刚通过 运行 以下命令和 运行 npm install
再次清除了缓存,它起作用了。
>npm cache clean --force
>npm install
因此,如果有人遇到这种情况,请按照以下步骤操作:
>npm install -g @angular/cli
>ng new my-app
>cd my-app
>npm cache clean --force
>npm install
>ng serve --open
一切顺利!
谢谢大家!
我昨天也遇到了同样的问题,我是怎么解决的..
1.Uninstall 当前 angular cli。 npm 卸载@angular/cli
2.Delete 文件夹:
3.Delete node_module 的临时文件(如果存在),在 cmd 中使用 %AppData%\npm-cache。
4.Restart系统。
5.Give 使用 npm install @angular/cli@ 进行全新安装,例如:6.0.2
- 大功告成,可以开始了。 :)
- 卸载 npm
- 安装angular客户端
我正在按照 Angular 站点上提到的所有说明进行安装和 运行 使用 Angular 7 的新项目,但是它给了我以下错误,我尝试了很多删除缓存的技巧删除整个节点模块和 npm 但没有任何效果,我需要帮助,请查看我从昨天开始不断收到的以下错误。
第一步:安装成功Angular7
C:\Users\me>npm install -g @angular/cli
C:\Users\me\AppData\Roaming\npm\ng ->
C:\Users\me\AppData\Roaming\npm\node_modules\@angular\cli\bin\ng
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4
(node_modules\@angular\cli\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for
fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current:
{"os":"win32","arch":"x64"})
+ @angular/cli@7.1.3
updated 1 package in 23.447s
第 2 步:切换文件夹并创建 my-app(但在创建 my-app 时出错,见下文)
C:\wamp\www>ng new my-app
? Would you like to add Angular routing? No
? Which stylesheet format would you like to use? CSS
CREATE my-app/angular.json (3768 bytes)
CREATE my-app/package.json (1305 bytes)
CREATE my-app/README.md (1022 bytes)
CREATE my-app/tsconfig.json (435 bytes)
CREATE my-app/tslint.json (2824 bytes)
CREATE my-app/.editorconfig (246 bytes)
CREATE my-app/.gitignore (576 bytes)
CREATE my-app/src/favicon.ico (5430 bytes)
CREATE my-app/src/index.html (292 bytes)
CREATE my-app/src/main.ts (372 bytes)
CREATE my-app/src/polyfills.ts (3694 bytes)
CREATE my-app/src/test.ts (642 bytes)
CREATE my-app/src/styles.css (80 bytes)
CREATE my-app/src/browserslist (388 bytes)
CREATE my-app/src/karma.conf.js (980 bytes)
CREATE my-app/src/tsconfig.app.json (166 bytes)
CREATE my-app/src/tsconfig.spec.json (256 bytes)
CREATE my-app/src/tslint.json (314 bytes)
CREATE my-app/src/assets/.gitkeep (0 bytes)
CREATE my-app/src/environments/environment.prod.ts (51 bytes)
CREATE my-app/src/environments/environment.ts (662 bytes)
CREATE my-app/src/app/app.module.ts (314 bytes)
CREATE my-app/src/app/app.component.html (1120 bytes)
CREATE my-app/src/app/app.component.spec.ts (978 bytes)
CREATE my-app/src/app/app.component.ts (210 bytes)
CREATE my-app/src/app/app.component.css (0 bytes)
CREATE my-app/e2e/protractor.conf.js (752 bytes)
CREATE my-app/e2e/tsconfig.e2e.json (213 bytes)
CREATE my-app/e2e/src/app.e2e-spec.ts (298 bytes)
CREATE my-app/e2e/src/app.po.ts (204 bytes)
npm WARN deprecated circular-json@0.5.9: CircularJSON is in maintenance
only, flatted is its successor.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: source-map@^0.4.2
(node_modules\scss-tokenizer\node_modules\source-map):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: zlib: unexpected end of file
npm ERR! code Z_BUF_ERROR
npm ERR! errno -5
npm ERR! zlib: unexpected end of file
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\me\AppData\Roaming\npm-cache\_logs18-12-
14T04_43_19_244Z-debug.log
Package install failed, see above.
第三步:然后我切换到my-app
C:\wamp\www>cd my-app
第 4 步:启动服务器,但这里也出现故障
C:\wamp\www\my-app>ng serve --open
Could not find module "@angular-devkit/build-angular" from
"C:\wamp\www\my-app".
Error: Could not find module "@angular-devkit/build-angular" from
"C:\wamp\www\my-app".
at Object.resolve (C:\Users\me\AppData\Roaming\npm\node_modules
\@angular\cli\node_modules\ @angular-devkit\core\node\resolve.js:141:11)
at Observable.rxjs_1.Observable [as _subscribe]
(C:\Users\me\AppData\Roaming\npm\node_modules
\@angular\cli\node_modules\@angular-devkit\architect\src\
architect.js:132:40)
at Observable._trySubscribe
(C:\Users\me\AppData\Roaming\npm\node_modules
\@angular\cli\node_modules\rxjs\internal\ Observable.js:44:25)
at Observable.subscribe
(C:\Users\me\AppData\Roaming\npm\node_modules
\@angular\cli\node_modules\rxjs\internal\Observable.js:30:22)
at
C:\Users\me\AppData\Roaming\npm\node_modules
\@angular\cli\node_modules\rxjs\internal\Observable.js:99:19
at new Promise (<anonymous>)
at Observable.toPromise
(C:\Users\me\AppData\Roaming\npm\node_modules
\@angular\cli\node_modules\rxjs\internal\Observable.js:97:16)
at ServeCommand.initialize
(C:\Users\me\AppData\Roaming\npm\node_modules
\@angular\cli\models\architect-command.js:88:94)
at process._tickCallback (internal/process/next_tick.js:43:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:779:11)
C:\wamp\www\my-app>
请给我一些建议,谢谢
delete the node_modules:
rm -rf node_modules 并删除了软件包-lock.json、
then re-install: npm install It works for me.
好的,我终于找到了解决方案!
我刚刚通过 运行 以下命令和 运行 npm install
再次清除了缓存,它起作用了。
>npm cache clean --force
>npm install
因此,如果有人遇到这种情况,请按照以下步骤操作:
>npm install -g @angular/cli
>ng new my-app
>cd my-app
>npm cache clean --force
>npm install
>ng serve --open
一切顺利! 谢谢大家!
我昨天也遇到了同样的问题,我是怎么解决的..
1.Uninstall 当前 angular cli。 npm 卸载@angular/cli
2.Delete 文件夹:
3.Delete node_module 的临时文件(如果存在),在 cmd 中使用 %AppData%\npm-cache。
4.Restart系统。
5.Give 使用 npm install @angular/cli@ 进行全新安装,例如:6.0.2
- 大功告成,可以开始了。 :)
- 卸载 npm
- 安装angular客户端