【问题标题】:Error while making ng serve Angular 4 (missing module)使 ng 服务 Angular 4 时出错(缺少模块)
【发布时间】:2018-03-04 08:17:25
【问题描述】:

我正在尝试使用 ng serve 在浏览器中打开我的项目,但每次运行该命令时,都会出现以下错误。

ERROR in ./node_modules/@angular/platform-browser/esm5/animations.js
Module not found: Error: Can't resolve '@angular/animations' in 
'/home/easy/Desktop/wa7shy2/crm/node_modules/@angular/platform-
browser/esm5'
resolve '@angular/animations' in 
'/home/easy/Desktop/wa7shy2/crm/node_modules/@angular/platform-
browser/esm5'
Parsed request is a module
using description file: 
/home/easy/Desktop/wa7shy2/crm/node_modules/@angular/platform-
browser/package.json (relative path: ./esm5)
Field 'browser' doesn't contain a valid alias configuration
after using description file: 
/home/easy/Desktop/wa7shy2/crm/node_modules/@angular/platform-
browser/package.json (relative path: ./esm5)
resolve as module
/home/easy/Desktop/wa7shy2/crm/node_modules/@angular/platform-
browser/esm5/node_modules doesn't exist or is not a directory
/home/easy/Desktop/wa7shy2/crm/node_modules/@angular/platform-
browser/node_modules doesn't exist or is not a directory
/home/easy/Desktop/wa7shy2/crm/node_modules/@angular/node_modules 
doesn't exist or is not a directory
/home/easy/Desktop/wa7shy2/crm/node_modules/node_modules doesn't exist 
or is not a directory
/home/easy/Desktop/wa7shy2/node_modules doesn't exist or is not a 
directory
/home/easy/Desktop/node_modules doesn't exist or is not a directory
/home/easy/node_modules doesn't exist or is not a directory
/home/node_modules doesn't exist or is not a directory
/node_modules doesn't exist or is not a directory
looking for modules in /home/easy/Desktop/wa7shy2/crm/node_modules
using description file: /home/easy/Desktop/wa7shy2/crm/package.json 
(relative path: ./node_modules)
Field 'browser' doesn't contain a valid alias configuration
after using description file: 
/home/easy/Desktop/wa7shy2/crm/package.json (relative path: 
./node_modules)
using description file: 
/home/easy/Desktop/wa7shy2/crm/node_modules/@angular/animations/
package.json (relative path: .)
no extension
Field 'browser' doesn't contain a valid alias configuration          
/home/easy/Desktop/wa7shy2/crm/node_modules/@angular/animations is not 
a file.ts
Field 'browser' doesn't contain a valid alias configuration          
/home/easy/Desktop/wa7shy2/crm/node_modules/@angular/animations.ts 
doesn't exist.js
Field 'browser' doesn't contain a valid alias configuration          
/home/easy/Desktop/wa7shy2/crm/node_modules/@angular/animations.js 
doesn't exist
as directory
existing directory
using path: 
/home/easy/Desktop/wa7shy2/crm/node_modules/@angular/animations/index
using description file: 

/home/easy/Desktop/wa7shy2/crm/node_modules/@angular/animations/ package.json(相对路径:./index)无扩展 字段“浏览器”不包含有效的别名配置
/home/easy/Desktop/wa7shy2/crm/src/@angular/animations/browser.ts 不存在.js

我很确定模块已经安装,我自己检查了路径,找到了所有说它没有找到的文件,尝试卸载并再次安装,仍然是同样的问题,有人告诉我这里出了什么问题。

我正在使用命令 npm install @angular/animations@latest --save 进行安装

【问题讨论】:

  • 您使用的是 Angular 4 还是 5?因为你的title说的是4,但是你的命令会安装最新版本的动画,即5.2.7
  • 5.2.7,我检查了 package.json,它说平台浏览器和动画是 5.2.7 但角度是 5.0.0
  • 它不起作用,这就是我发布问题的原因 -_- 感谢您的大力支持
  • 您是否使用 CLI 命令生成了您的应用程序?可以分享一下你的 angular-cli 和 tsconfig 文件吗,好像有错误的 config To o

标签: angular typescript module


【解决方案1】:

我解决了我的问题,@angular/animations 文件夹是空的,所以我将备份 @angular 文件夹中丢失的文件复制到其中,现在它运行良好。

【讨论】:

    猜你喜欢
    • 2022-01-01
    • 2018-03-12
    • 2019-02-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-22
    • 2020-02-22
    • 2020-01-14
    相关资源
    最近更新 更多