(我是星球Angular2的新手(从垂死的行星
Flex/Actionscript 移民,所以请原谅这个天真的问题)
在我的项目中运行"ng build"命令后,我发现了一个致命的错误Angular CLi,我最终会在"dist"目录中运行一个正常运行的项目 - 我可以在浏览器中运行,放在一个服务器?
我最终得到了一个充满正确命名的东西的文件夹,等等.我在这里缺少一步吗?
正如标题所说,当我运行"ng serve"时,angular-cli会产生正常的css,而我希望得到缩小的版本.是否有任何特定的设置用于angular-cli-build,或者一些额外的插件来安装和使用?
这是我的angular-cli-build.js
var Angular2App = require('angular-cli/lib/broccoli/angular2-app');
module.exports = function(defaults) {
return new Angular2App(defaults, {
vendorNpmFiles: [
'systemjs/dist/system-polyfills.js',
'systemjs/dist/system.src.js',
'zone.js/dist/**/*.+(js|js.map)',
'es6-shim/es6-shim.js',
'reflect-metadata/**/*.+(ts|js|js.map)',
'rxjs/**/*.+(js|js.map)',
'@angular/**/*.+(js|js.map)',
'angular2-cookie/**/*.js'
]
});
};
Run Code Online (Sandbox Code Playgroud) 当我运行时ng serve,文件生成和存储在哪里?我需要解决应用程序的原因,ng serve但不能解决生产构建问题.
忘记提到我正在使用angular-cli的webpack版本.
可以说我有以下方法:
getErrorMessage(state: any, thingName?: string) {
const thing: string = state.path || thingName;
const messages: string[] = [];
if (state.errors) {
for (const errorName in state.errors) {
switch (errorName) {
case 'required':
messages.push(`You must enter a ${thing}`);
break;
case 'minlength':
messages.push(`A ${thing} must be at least ${state.errors['minlength'].requiredLength}characters`);
break;
case 'pattern':
messages.push(`The ${thing} contains illegal characters`);
break;
case 'validateCardNumberWithAlgo':
messages.push(`Card doesnt pass algo`);
break;
}
}
}
return messages;
}
Run Code Online (Sandbox Code Playgroud)
我跑的时候
ng lint
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
for(... in ...)语句必须使用if语句进行过滤
看一下类似的问题,我认为答案不适用于我的情况.所有switch语句都在if-else-if阶段的类别中.
tslint应该将switch语句视为if语句的形式,但它没有?!
如何解决此错误,因为我无法安装Angular.
请参阅以下例外:
C:\Users\absin\node>npm install -g @angular/cli
npm ERR! code ETARGET
npm ERR! notarget No matching version found for require-from-string@^1.1.0
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget
npm ERR! notarget It was specified as a dependency of 'cosmiconfig'
npm ERR! notarget
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\absin\AppData\Roaming\npm-cache\_logs\2018-01-06T19_07_00_000Z-debug.log
Run Code Online (Sandbox Code Playgroud)
即使在时间解决之后:
npm install https://github.com/floatdrop/require-from-string/tarball/v1.1.0 --save
npm …Run Code Online (Sandbox Code Playgroud) 显然,声明默认样式表扩展的方式从Angular 6开始改变了.该styleExt物业angular.json不再被承认.
对于新的项目,这可以通过在命令行选项来设置--style=scss的new命令.
但是,如何在我从Angular <5迁移的项目或者在项目创建期间忘记执行此操作时更改此项目?
这个问题与Angular第5版到第6版的重大变化有关.
我查看了此处有关此问题的大量帖子并尝试了它们,但没有成功解决此问题。
我在 MacOS 上,这是我迄今为止根据我在此处找到的建议所做的工作,但我仍然收到此错误
~~ sudo npm uninstall -g angular-cli
~~ sudo npm uninstall -g @angular/cli
~~ sudo npm cache clean --force
~~ sudo npm install -g @angular/cli
Run Code Online (Sandbox Code Playgroud)
这输出:
/usr/local/Cellar/node/11.10.0/bin/ng -> /usr/local/Cellar/node/11.10.0/lib/node_modules/@angular/cli/bin/ng
> @angular/cli@8.3.6 postinstall /usr/local/Cellar/node/11.10.0/lib/node_modules/@angular/cli
> node ./bin/postinstall/script.js
+ @angular/cli@8.3.6
added 245 packages from 185 contributors in 8.784s
Run Code Online (Sandbox Code Playgroud)
但是,发出以下命令不起作用:
~~ ng version
-bash: ng: command not found
Run Code Online (Sandbox Code Playgroud)
有些人建议链接,所以我也尝试过:
~~ sudo npm link @angular/cli
Run Code Online (Sandbox Code Playgroud)
,输出如下:
/Users/dinob/node_modules/@angular/cli -> /usr/local/Cellar/node/11.10.0/lib/node_modules/@angular/cli
Run Code Online (Sandbox Code Playgroud)
,但 ng 版本仍然无法正常工作:
~~ ng version
-bash: ng: command not found
Run Code Online (Sandbox Code Playgroud)
许多帖子建议 …
将 ng-bootstrap 安装到我的 Angular-CLI(11.0.4) 时出现错误。什么时候
ng add @ng-bootstrap/ng-bootstrap
Run Code Online (Sandbox Code Playgroud)
还有我的日志文件
[error] Error: npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: front@0.0.0
npm ERR! Found: @angular/compiler@11.0.9
npm ERR! node_modules/@angular/compiler
npm ERR! @angular/compiler@"~11.0.4" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @angular/compiler@"11.1.1" from @angular/localize@11.1.1
npm ERR! node_modules/@angular/localize
npm ERR! peer @angular/localize@"^11.0.0" from @ng-bootstrap/ng-bootstrap@9.0.2
npm ERR! node_modules/@ng-bootstrap/ng-bootstrap
npm ERR! @ng-bootstrap/ng-bootstrap@"*" from the root project
npm ERR!
npm …Run Code Online (Sandbox Code Playgroud) 升级到 Angular 13 后,使用--code-coverage运行的测试失败,并出现缺少某些插件的错误
\n我正在使用karma-coverage-istanbul-reporter,karma.conf.js这导致了一些问题。我什至将其替换为默认值karma-coverage,但仍然看到相同的错误
ng test waxion --no-watch --code-coverage --browsers ChromeHeadless\nRun Code Online (Sandbox Code Playgroud)\n\xe2\xa0\x8b Generating browser application bundles (phase: setup)...20 11 2021 17:34:24.723:ERROR [reporter]: Can not load reporter "coverage", it is not registered!\n Perhaps you are missing some plugin?\n\xe2\xa0\x99 Generating browser application bundles (phase: building)...20 11 2021 17:34:27.353:INFO [karma-server]: Karma v6.3.9 server started at http://localhost:9876/\n20 11 2021 17:34:27.353:INFO [launcher]: Launching browsers Chrome with concurrency unlimited\n20 11 2021 17:34:27.353:ERROR [karma-server]: Error: Found …Run Code Online (Sandbox Code Playgroud) angular-cli ×10
angular ×8
css ×2
node.js ×2
typescript ×2
angular6 ×1
install ×1
macos ×1
ng-bootstrap ×1
npm ×1
npm-install ×1
sass ×1
terminal ×1
tslint ×1