Ama*_*man 43 typescript angular angular6
"ng serve"中是否有人面临以下警告?
警告在./node_modules/@angular/compiler/src/util.js 10:24-31严重依赖:require函数的使用方式是无法静态提取依赖关系ℹ"wdm":编译时带有警告.
角度版本:
Angular CLI:6.0.8节点:8.11.3操作系统:darwin x64 Angular:6.0.9 ...动画,通用,编译器,编译器 - cli,核心,表单... http,语言服务,平台浏览器..平台浏览器动态,路由器,升级
我尝试更新CLI和Angular但没有成功.util.js中的代码如下所示:
function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define("@angular/compiler/src/util", ["require", "exports"], factory);
}
}Run Code Online (Sandbox Code Playgroud)
小智 102
我收到了这个错误并发现了这个:https:
//fluin.io/blog/critical-dependency-cannot-be-statically-extracted,作者显示他收到了相同的警告.但是,我没有使用Angular Elements,但我知道它可能与同一个问题有关,所以我继续检查我是否在我的@angular/compiler/src/core任何导入中使用.
而我确实这样做了.修复就像删除导入行一样简单,在我的例子中是:
import { ViewEncapsulation } from '@angular/compiler/src/core';
Run Code Online (Sandbox Code Playgroud)
然后编辑器自动导入如下:
import { Component, OnInit, ViewEncapsulation } from '@angular/core';
Run Code Online (Sandbox Code Playgroud)
我希望它有所帮助.
mim*_*imo 21
我遇到了同样的错误,当我错误地EventEmitter从而protractor不是@angular/core.
更改import { EventEmitter } from 'protractor';以import { EventEmitter } from '@angular/core';修复它。
小智 5
如果您从 src 路径导入,则会抛出此警告
将组件导入语句从
import { ChangeDetectionStrategy, ViewEncapsulation } from '@angular/compiler/src/core';
Run Code Online (Sandbox Code Playgroud)
到
import { ViewEncapsulation, ChangeDetectionStrategy} from '@angular/core';
Run Code Online (Sandbox Code Playgroud)
小智 5
我发现了一个类似的问题:
./node_modules/@angular/compiler/src/util.js:10:24-31 - 警告:关键依赖项:require 函数的使用方式无法静态提取依赖项
我记得使用stringify而不是JSON.stringify并且自动导入(使用 vs code)为:
import { stringify } from '@angular/compiler/src/util';
Run Code Online (Sandbox Code Playgroud)
我删除了此自动导入并将代码更正为 JSON.stringify。
| 归档时间: |
|
| 查看次数: |
17559 次 |
| 最近记录: |