Git Pull 后 Angular CLI 项目缺少模块错误

标签 angular angular-cli

我在 Angular/CLI 1.2.1 中使用 Angular4。我能够很好地初始化并使用 ng serve 在本地运行应用程序。但是,在推送到远程 git 存储库然后将我的工作拉到另一台机器上后 - 我收到错误。

重建步骤
1. 从远程 git 仓库中拉取使用 Angular CLI 创建的项目。
2. NPM安装。
3. 服务。

错误信息

ERROR in D:/application/src/app/app.component.ts (1,27): Cannot find module '@angular/core'.

ERROR in D:/application/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 D:/application/src/app/app.module.ts (1,31): Cannot find module '@angular/platform-browser'.

ERROR in D:/application/src/app/app.module.ts (2,26): Cannot find module '@angular/core'.

ERROR in D:/application/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 D:/application/src/main.ts (1,32): Cannot find module '@angular/core'.

ERROR in D:/application/src/main.ts (2,40): Cannot find module '@angular/platform-browser-dynamic'.

ERROR in Could not resolve module @angular/core

ERROR in D:/application/src/main.ts (1,32): Cannot find module '@angular/core'.

ERROR in D:/application/src/main.ts (2,40): Cannot find module '@angular/platform-browser-dynamic'.

ERROR in D:/application/src/app/app.module.ts (1,31): Cannot find module '@angular/platform-browser'.

ERROR in D:/application/src/app/app.module.ts (2,26): Cannot find module '@angular/core'.

ERROR in D:/application/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 D:/application/src/app/app.component.ts (1,27): Cannot find module '@angular/core'.

ERROR in D:/application/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.

webpack: Failed to compile.

NPM 安装输出

npm WARN prefer global node-gyp@3.6.2 should be installed with -g

node-sass@4.5.3 install D:\application\node_modules\node-sass node scripts/install.js

缓存二进制文件位于 C:\Users\user\AppData\Roaming\npm-cache\node-sass\4.5.3\win32-x64-48_binding.node

node-sass@4.5.3 postinstall D:\application\node_modules\node-sass node scripts/build.js

二进制文件位于 D:\application\node_modules\node-sass\vendor\win32-x64-48\binding.node 测试二进制文件 二进制没问题

...继续安装,没有错误(包括@angular/core 和其他包)。

最佳答案

从 Angular 项目层次结构中删除 node_modules 文件夹并使用 npm install 重新安装所有包的简单方法

关于Git Pull 后 Angular CLI 项目缺少模块错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45337324/

相关文章:

javascript - 问题在 angular5 中添加第三方(外部)js 库

javascript - 如何在猫头鹰日期时间中选择日期后自动关闭日历?

javascript - 通过字符串注入(inject)和解析 Angular2 提供程序

Angular - ngOnInit 中的两个订阅导致对象 'undefined'

Angular:将自定义 HTTP 响应 header 添加到 dev `ng serve`

javascript - ng --version 显示 Angular 不支持当前版本的 Node (16.8.0)

angularjs - 使用 Angular CLI 的 Web 应用程序不显示 bootstrap-sass 字形

angularjs - 'Content-Type' : 'application/x-www-form-urlencoded do in http post method 是什么

html - overflow-x 不工作,屏幕上只显示几列

javascript - 根据环境配置基本 URL