执行命令时:
ng generate route someName
Run Code Online (Sandbox Code Playgroud)
我收到这样的错误:
无法启动守望者; 回退到NodeWatcher以获取文件系统事件.访问http://ember-cli.com/user-guide/#watchman了解更多信息.由于路由器的变化,路由生成已暂时禁用.您可以在此处找到有关新路由器的更多信息:http: //victorsavkin.com/post/145672529346/angular-router
提供的链接没有帮助
我正在尝试使用angular-cli进行AOT编译设置.我有一个从抽象类继承的指令,我在编译期间遇到一个错误,即angular无法确定抽象类属于哪个模块.我无法将它添加到NgModule的声明数组中,那么正确的方法是什么呢?我的代码结构如下所示,
//...imports
export abstract class TutorialDirective {
//...base class logic
}
@Directive({
selector: '[tut]',
exportAs: 'tut'
})
export class DefaultTutorialDirective extends TutorialDirective {
//...calls into the base class for some shared stuff.
}
Run Code Online (Sandbox Code Playgroud)
错误看起来像这样
ERROR in Cannot determine the module for class TutorialDirective in /test-app/src/app/tutorial/directive/tutorial.directive.ts!
Run Code Online (Sandbox Code Playgroud)
我的AppModule:
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { HttpModule } from '@angular/http';
import { AppComponent } from './app.component';
import { TutorialService } …Run Code Online (Sandbox Code Playgroud) 在使用Angular CLI构建的Angular 2应用程序中,我按照官方安装指南设置了Angular 2 Material组件.
Angular 2 Material将其主要CSS样式放在页面中,<head>总是低于我的自定义CSS样式.如果我需要覆盖它们,这会对我产生影响.
如何强制Angular 2 Material将其核心CSS样式置于我在Angular CLI main(entry)CSS文件中定义的样式之上?
在执行ng build --prod --base-href ./来构建我的cordova应用程序时,最终输出将引发如下错误。
无法加载模块脚本:服务器以非JavaScript MIME类型“”响应。根据HTML规范对模块脚本强制执行严格的MIME类型检查。
我最终通过将类型模块更改为text / javascript来解决此问题
src =“ runtime-es2015.858f8dd898b75fe86926.js” type =“ module”>
src =“ runtime-es2015.858f8dd898b75fe86926.js” type =“ text / javascript”>
在angular.json文件中是否可以解决某些问题,还是我在这里错过了什么?
我将 Angular 从 v11 升级到了 v12。我收到此错误,但我不知道为什么。构建配置或 tsconfig 没有变化。
我希望能够使用Visual Studio Code调试Angular2应用程序.
这是我的环境:
使用angular-cli创建一个新项目:
ng new test-VSC-debug
cd test-VSC-debug
Run Code Online (Sandbox Code Playgroud)
然后我打开VSC并加载项目: File/open folder
我点击debug的标志,我configure launch.json的选择chrome.它生成以下文件:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Chrome against localhost, with sourcemaps",
"type": "chrome",
"request": "launch",
"url": "http://localhost:8080",
"sourceMaps": true,
"webRoot": "${workspaceRoot}"
},
{
"name": "Attach to Chrome, with sourcemaps",
"type": "chrome",
"request": "attach",
"port": 9222,
"sourceMaps": true,
"webRoot": "${workspaceRoot}"
}
]
}
Run Code Online (Sandbox Code Playgroud)
然后我通过运行启动angular2项目:
ng serve …Run Code Online (Sandbox Code Playgroud) google-chrome-devtools visual-studio-code angular-cli angular
我正在尝试为Windows安装angular-cli.我知道命令是npm install -g angular-cli,但是一旦我运行这个命令,我就会尝试新的但是我得到一个错误,说"ng不是一个公认的命令"我在这里检查了其他问题说你必须将文件夹添加到PATH变量,但是当我检查文件夹时,我试图安装angular-cli,我甚至看不到任何东西.
在这里你可以看到我已经使用提供的命令安装了angular-cli,并且使用了"ng"命令注册和错误:

在这里你可以看到一个没有angular-cli文件夹的空文件夹或者其他任何东西:

请注意我对cmd和angular很新,我真的不知道在这里采取什么步骤.
我正在使用节点v6.11.2,npm v5.3.0和angular/cli v1.2.7.
对于我的大多数npm安装,我突然收到以下错误消息.从来没见过......
mmeppiel@MC-LT-MMEPPIEL MINGW64 ~/Desktop/Angular Solutions/my-app (master)
$ npm install --save bootstrap@4.0.0-alpha.6 font-awesome
npm ERR! path C:\Users\mmeppiel\Desktop\Angular Solutions\my-app\node_modules\fs events\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall lstat
npm ERR! Error: EPERM: operation not permitted, lstat 'C:\Users\mmeppiel\Desktop \Angular Solutions\my-app\node_modules\fsevents\node_modules'
npm ERR! at Error (native)
npm ERR! { Error: EPERM: operation not permitted, lstat 'C:\Users\mmeppiel\Desk top\Angular Solutions\my-app\node_modules\fsevents\node_modules'
npm ERR! at Error (native)
npm ERR! stack: 'Error: EPERM: operation not permitted, lstat \'C:\\Users\\mme ppiel\\Desktop\\Angular Solutions\\my-app\\node_modules\\fsevents\\node_modules\ '\n at …Run Code Online (Sandbox Code Playgroud) 我有一个Angular(4.3.2)应用程序,我想在其上执行AOT构建.应用程序是使用@angular/cli.我有两个搭建的组件ng generate和一个模块,其中两个都作为声明包含在内:
import {PrivateComponent} from './private.component/private.component';
NgModule({
imports: [
// other imports
PrivateRoutingModule
],
declarations: [
...some other components,
PrivateComponent,
AppTopBarComponent
]
// other stuff
})
export class PrivateModule {}
Run Code Online (Sandbox Code Playgroud)
私有组件也用于模块的路由:
const routes: Routes = [
{path: '', component: PrivateComponent, children: // other components}
]
@NgModule({
imports: [RouterModule.forChild(routes)] // this is the Angular built-in router module
})
export class PrivateRoutingModule {}
Run Code Online (Sandbox Code Playgroud)
注意:路由是如何在另一个模块定义和导入PrivateModule
的AppTopBarComponent内部使用的PrivateComponent's模板.所以两者都被使用和宣布.但是当我使用"node_modules/.bin/ngc" -p tsconfig-aot.json(我在Windows 10上)时,我收到此错误消息:
Cannot determine the …
在升级到 Angular 11 之前,我通过以下命令运行了代码覆盖率的单元测试:
ng test --project my-app --code-coverage true
Run Code Online (Sandbox Code Playgroud)
当我将我的项目升级到 Angular 11 时,我仍然能够进行我的代码覆盖率测试,但是我开始收到一条消息,说“'karma-coverage-istanbul-reporter' 的使用自版本 11 以来已被弃用”。它要求我安装 karma-coverage 并更新 karma.conf.js。所以我做了它所要求的。我通过以下命令安装了 karma-coverage 和 karma:
npm install karma karma-coverage --save-dev
Run Code Online (Sandbox Code Playgroud)
结果,我在 package.json 中的 devDependencies 下看到了 karma 条目:
ng test --project my-app --code-coverage true
Run Code Online (Sandbox Code Playgroud)
我更新了我的 karma.conf.js 文件。以下是存在的内容,除了我的评论外,一切都和原来一样:
npm install karma karma-coverage --save-dev
Run Code Online (Sandbox Code Playgroud)
进行此更新后,发生了两件事,我不知道为什么。
当我运行正常的代码覆盖率命令时,我收到以下错误:“服务器在端口 9876 上启动失败:错误:必须安装 karma-coverage 才能运行代码覆盖率。” 我确实安装了它,正如我的 package.json 所示,但由于某种原因,我的项目无法识别这一点。此外,如果我将 karma-coverage-istanbul-reporter require 方法添加回我的 conf.js 文件,coverage 工作正常,但我仍然收到该弃用消息。谁能向我解释为什么我可能会收到此错误?
当我在没有覆盖的情况下运行测试时,我现在收到多个以前从未收到过的警告,例如:“无法从文件扩展名确定文件类型,默认为 js。要使警告静音,请指定 C:/Angular/ 的有效类型配置文件中的 my-project/projects/my-app/src/app/app.component.spec.ts。” 我需要做什么来解决这个问题?
编辑:我找到了答案。在coverageReporter 对象中,您需要将fixWebpackSourcePaths 属性添加为true:
"karma": "^5.2.3",<br>
"karma-coverage": "^2.0.3"
Run Code Online (Sandbox Code Playgroud) unit-testing karma-jasmine karma-coverage angular-cli angular11
angular-cli ×10
angular ×7
node.js ×2
npm ×2
npm-install ×2
angular-aot ×1
angular11 ×1
angular8 ×1
angularjs ×1
aot ×1
build ×1
ng-build ×1
routes ×1
typescript ×1
unit-testing ×1