为什么在node_modules中有@ angular/core,但是仍然出现此错误? [英] Why do I have @angular/core in node_modules, but still get this error?

查看:505
本文介绍了为什么在node_modules中有@ angular/core,但是仍然出现此错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从这里从angular.io下载了一个示例项目 https://angular.io/generation/zips/cli-quickstart/cli-quickstart.zip

I downloaded an example project from angular.io , from here https://angular.io/generated/zips/cli-quickstart/cli-quickstart.zip

按照本教程中的说明在根文件夹中运行npm install

and ran npm install in the root folder, as in this tutorial

https://www.youtube.com/watch?v=bJKejcQJqHE

并且为什么,尽管我在node_modules和package.json中都有相应的角度包,但我还是得到了:

and somewhy, although I have the corresponding angular packages in both node_modules and package.json, still I got this:

Hash: faeff28da7a6ba00851d                    
Time: 8547ms
chunk    {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 171 kB {4} [initial] [rendered]
chunk    {1} main.bundle.js, main.bundle.js.map (main) 5.41 kB {3} [initial] [rendered]
chunk    {2} styles.bundle.js, styles.bundle.js.map (styles) 11.5 kB {4} [initial] [rendered]
chunk    {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.18 MB [initial] [rendered]
chunk    {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]

ERROR in /home/ivan/anglr-lrn/src/app/app.component.ts (1,27): Cannot find module '@angular/core'.

ERROR in /home/ivan/anglr-lrn/src/app/app.component.ts (8,14): Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.

ERROR in /home/ivan/anglr-lrn/src/app/app.module.ts (1,31): Cannot find module '@angular/platform-browser'.

ERROR in /home/ivan/anglr-lrn/src/app/app.module.ts (2,26): Cannot find module '@angular/core'.

ERROR in /home/ivan/anglr-lrn/src/app/app.module.ts (16,14): Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.

ERROR in /home/ivan/anglr-lrn/src/main.ts (1,32): Cannot find module '@angular/core'.

ERROR in /home/ivan/anglr-lrn/src/main.ts (2,40): Cannot find module '@angular/platform-browser-dynamic'.

ERROR in Could not resolve module @angular/core
webpack: Failed to compile.
webpack: Compiling...
Hash: faeff28da7a6ba00851d                                               
Time: 807ms
chunk    {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 171 kB {4} [initial]
chunk    {1} main.bundle.js, main.bundle.js.map (main) 5.41 kB {3} [initial]
chunk    {2} styles.bundle.js, styles.bundle.js.map (styles) 11.5 kB {4} [initial]
chunk    {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.18 MB [initial]
chunk    {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry]

ERROR in /home/ivan/anglr-lrn/src/app/app.component.ts (1,27): Cannot find module '@angular/core'.

ERROR in /home/ivan/anglr-lrn/src/app/app.component.ts (8,14): Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.

ERROR in /home/ivan/anglr-lrn/src/app/app.module.ts (1,31): Cannot find module '@angular/platform-browser'.

ERROR in /home/ivan/anglr-lrn/src/app/app.module.ts (2,26): Cannot find module '@angular/core'.

ERROR in /home/ivan/anglr-lrn/src/app/app.module.ts (16,14): Experimental support for decorators is a feature that is subject to change in a future release. Set the 'experimentalDecorators' option to remove this warning.

ERROR in /home/ivan/anglr-lrn/src/main.ts (1,32): Cannot find module '@angular/core'.

ERROR in /home/ivan/anglr-lrn/src/main.ts (2,40): Cannot find module '@angular/platform-browser-dynamic'.
webpack: Failed to compile.

推荐答案

这在类似情况下有效:

在计算机上卸载NodeJS .

如果已与可下载的软件包安装程序一起安装-(添加删除程序">选择NodeJS,然后单击卸载")

If installed with the downloadable package installer - (Add Remove Programs > Select NodeJS and click uninstall)

下载并安装NodeJS 6.10.3( https://nodejs.org/dist/v6.10.3/node-v6.10.3-x64.msi )

Download and install NodeJS 6.10.3 (https://nodejs.org/dist/v6.10.3/node-v6.10.3-x64.msi)

清理node_modules文件夹

rm -rf node_modules/

清理所有临时文件夹

运行这些命令

npm uninstall -g angular-cli
npm cache clean
npm install -g @angular/cli
npm install

这篇关于为什么在node_modules中有@ angular/core,但是仍然出现此错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆