为什么我的node_modules中有@angular/core,但仍然出现此错误?

2024-02-18

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

并在根文件夹中运行 npm install,如本教程所示

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

不知何故,尽管我在node_modules和package.json中都有相应的角度包,但我仍然得到了这个:

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 并单击卸载)

下载并安装 NodeJS 6.10.3 (https://nodejs.org/dist/v6.10.3/node-v6.10.3-x64.msi 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
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

为什么我的node_modules中有@angular/core,但仍然出现此错误? 的相关文章

  • 缺少节点-v59-linux-x64/grpc_node.node

    我正在尝试在我的服务器中使用 Firebase admin SDK 当我部署时 出现错误 我在 firebase admin node module 映射中缺少文件 node v59 linux x64 grpc node node 我在包
  • 找不到“节点”的类型定义文件

    更新 Angular Webpack 和 TypeScript 后出现奇怪的错误 知道我可能会错过什么吗 当我使用 npm start 运行应用程序时 出现以下错误 at loader Cannot find type definition
  • 如何让 vsCode 了解自动补全的深度依赖导入?

    我创建了多个角度库 让我可以使用一堆组件更快地创建网站 例如 sidenav 卡片 我创建了一个 超级库 来导入所有这些库 这样我就可以使用npm i myWebsiteBundle立即下载所有依赖项 我已将每个类似的插件列入白名单ng p
  • NodeJS hmac 摘要问题与重音

    我正在对以下代码与 Ruby PHP 和 NodeJS 进行并排比较 使用 NodeJS 得到错误的响应crypto module PHP hash hmac sha256 text Ruby OpenSSL HMAC hexdigest
  • 如何使用Create React App安装React

    嗨 我对反应真的很陌生 我不知道如何实际安装它 也不知道我需要做什么才能在其中编写代码 我下载了node js并且安装了v12 18 3以及NPM 6 14 6 但是每次我尝试在许多网站上提到的create react app安装方法中输入
  • 根据特定字符获取整个字符串或子字符串

    我有一个包含 MIME 类型的字符串 例如application json 现在我想将其与实际的 HTTP 标头进行比较 在本例中content type 如果标头包含 MIME 类型 那么就很简单 if mimeType contentT
  • Angular 7测试重试当模拟http请求无法实际重试时

    我有以下尝试使用 OAuth 的拦截器refresh token每当获得任何 401 错误 响应时 基本上 刷新令牌是在第一个 401 请求上获取的 获取后 代码会等待 2 5 秒 在大多数情况下 第二个请求不会触发错误 但如果触发错误 令
  • Node.js 和 Passport 对象没有 validPassword 方法

    我正在使用 Node js Express Passport 创建一个简单的身份验证 本地 到目前为止我所达到的效果是 当输入错误的用户名或密码时 用户将被重定向到错误页面 但是当用户输入正确的用户名和密码时 我收到此错误 node mod
  • 在具有多级分组的 HTML 表格中显示数据

    我必须通过使用 rowspan 进行分组来显示 HTML 表中的一些数据 下面是预期的 GUI 我有如下所示的 JSON 数据 JSON数据here https jsoneditoronline org id 1014438e5489485
  • 我在 MacBook M1 max 中的 nodejs 连接到数据库 oracle 时遇到问题帮助我

    Node js 中的错误消息 nodemon 启动node server js错误 错误 DPI 1047 无法找到 64 位 Oracle 客户端库 dlopen Users pitidev ldb Downloads instantcl
  • 如何在 Angular 库中包含图像?

    我创建了一个简单的 Angular 库 我希望我的库也显示图像 问题是 如果我将图像包含在库的模块文件夹中 然后从模块内部引用它 则会收到 404 错误 据我所知 在 Angular 项目中 图像必须放置在 assets 文件夹中 但我确实
  • 我的客户端 socket.io 在哪里?

    我使用 Express 和 React Engine 创建了一个同构 React 应用程序 现在我正在尝试连接socket io 在快速设置中我有 var express require express var app express va
  • 在heroku上部署时出错,/bin/sh: 1: webpack: not found

    这是我在 heroku 网站上手动部署时遇到的错误 首先 我在 json 文件中遇到错误 因此我指定了正在运行的 npm yarn 和 node 版本 这些错误似乎已经清除 现在我就是这样的人 并且已经搜索了谷歌 但似乎找不到太多关于修复它
  • Plesk Windows 部署 Node.js

    我创建了一个以 Node js 作为后端的 Angular 项目 这是服务器文件结构 Home directory httpdocs node hm dist browser folder server folder server js p
  • 如何仅在 NextJS 站点构建期间使用 getInitialProps?

    当使用 NextJS 构建静态站点时 我想要getInitialProps方法仅在构建步骤期间触发 而不是在客户端上触发 在构建步骤中 NextJS 运行getInitialProps 方法 https nextjs org docs fe
  • 如何在 Angular 4 项目中使用 ActiveXObject

    我正在尝试使用 ActiveXObject 如下所示 getActiveXObject pdfCtrl return new ActiveXObject pdfCtrl checkPDF let plugin null if this ge
  • 在 angular2 中过滤数组

    我正在研究如何在 Angular2 中过滤数据数组 我研究过使用自定义管道 但我觉得这不是我想要的 因为它似乎更适合简单的表示转换 而不是过滤大量数据 数组排列如下 getLogs Array
  • Angular 4 与 Webpack 2,动态加载脚本

    我刚刚在一个项目中尝试使用 Angular 4 和 Webpack 2 我试图在 ngOnInit 期间加载一些脚本 但遇到了一些问题 问题1 我的 ngOnInit 中有以下代码 System import node modules jq
  • 在d3.js中将2D形状转换为3D,并根据ANGULAR中的值调整高度

    我正在使用 d3 js v6 创建以下 2D 图表表示的 3D 图表 这个圆圈中有多个正方形 每个正方形都根据值分配了一种颜色 值越大 正方形越暗 现在我想将其转换为 3D 形状 其中当值变高时 只有特定正方形的高度会增加 因此结果在某种程
  • Mongoose 和 Promise:如何获取查询结果数组?

    使用猫鼬从数据库和 Q 中查询结果以获取承诺 但发现很难只获取可用用户列表 目前我有一些这样的东西 var checkForPerson function person people mongoose model Person Person

随机推荐