我尝试使用我的特定配置为我的 Angular 应用程序提供服务,但 Angular 无法识别它:
$ ng serve --configuration=fr
An unhandled exception occurred: Configuration 'fr' is not set in the workspace.
See "/tmp/ng-nyZPjp/angular-errors.log" for further details.
Run Code Online (Sandbox Code Playgroud)
我的 angular.json :
"configurations": {
"fr": {
"aot": true,
"outputPath": "dist/fr/",
"i18nFile": "src/i18n/messages.fr.xlf",
"i18nFormat": "xlf",
"i18nLocale": "fr",
"i18nMissingTranslation": "error",
"baseHref": "/fr/"
},
"en": {
"aot": true,
"outputPath": "dist/en/",
"i18nFile": "src/i18n/messages.en.xlf",
"i18nFormat": "xlf",
"i18nLocale": "en",
"i18nMissingTranslation": "error",
"baseHref": "/en/"
},
...
Run Code Online (Sandbox Code Playgroud)
ng serve --configuration=en 完美运行
ng build和ng serve之间有什么区别?在构建和ng服务之后,究竟完成或改变了什么?
当我使用Angular CLI(8.0.0)生成项目时,运行ng serve,在Internet Explorer中打开应用程序,然后出现空白屏幕。
我看了看polyfills.ts文件,并取消了以下几行的注释:
import 'classlist.js';
import 'web-animations-js';
Run Code Online (Sandbox Code Playgroud)
我也删除了所有core.js导入,因为Angular 8直接支持core.js 3.0。
我也跑了npm i。
package.json:
"dependencies": {
"@angular/animations": "~8.0.0",
"@angular/common": "~8.0.0",
"@angular/compiler": "~8.0.0",
"@angular/core": "~8.0.0",
"@angular/forms": "~8.0.0",
"@angular/platform-browser": "~8.0.0",
"@angular/platform-browser-dynamic": "~8.0.0",
"@angular/router": "~8.0.0",
"classlist.js": "^1.1.20150312",
"rxjs": "~6.4.0",
"tslib": "^1.9.0",
"web-animations-js": "^2.3.1",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.800.0",
"@angular/cli": "~8.0.0",
"@angular/compiler-cli": "~8.0.0",
"@angular/language-service": "~8.0.0",
"@types/node": "~8.9.4",
"@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "^5.0.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1", …Run Code Online (Sandbox Code Playgroud) 当我尝试构建运行以下命令的项目时:
ng build --environment=prod --aot=false --output-path="..." --base-href="..."
Run Code Online (Sandbox Code Playgroud)
你似乎不依赖@angular/core.
这是一个错误,但是,我不明白为什么因为它之前运作良好.
我试着这样做:
npm install @angular/core
Run Code Online (Sandbox Code Playgroud)
但我得到这个错误:
error at Error (native) error { Error: EACCES: permission denied, chown '' error at Error (native) error errno: -13, error code: 'EACCES', error syscall: 'chown', error Please try running this command again as root/Administrator. verbose exit [ -13, true ]
我也试图摆脱node_modules,然后安装npm:但我得到同样的错误.
当我运行以下命令时:
ng serve
Run Code Online (Sandbox Code Playgroud)
我有另一个错误:
The "@angular/compiler-cli" package was not properly installed. Error: Error: Cannot find module '@angular/compiler-cli'
这是我的package.json:
"ng": …Run Code Online (Sandbox Code Playgroud) 目前我正在开发一个托管在客户端服务器上的项目.对于新的"模块",无意重新编译整个应用程序.也就是说,客户端希望在运行时更新路由器/延迟加载的模块.我已经尝试了几件事,但我无法让它发挥作用.我想知道你们中是否有人知道我还能尝试什么或者我错过了什么.
有一点我注意到,在构建应用程序时,我尝试使用angular cli的大部分资源都被webpack捆绑成单独的块.这似乎是合乎逻辑的,因为它使用了webpack代码拆分.但是如果在编译时模块还不知道怎么办(但是编译后的模块存储在服务器的某个地方)?捆绑不起作用,因为它找不到要导入的模块.并且使用SystemJS将在系统上找到时加载UMD模块,但也通过webpack捆绑在一个单独的块中.
我已经尝试过的一些资源;
我已经尝试并实现了一些代码,但目前还没有工作;
使用普通的module.ts文件扩展路由器
this.router.config.push({
path: "external",
loadChildren: () =>
System.import("./module/external.module").then(
module => module["ExternalModule"],
() => {
throw { loadChunkError: true };
}
)
});
Run Code Online (Sandbox Code Playgroud)
正常SystemJS导入UMD捆绑包
System.import("./external/bundles/external.umd.js").then(modules => {
console.log(modules);
this.compiler.compileModuleAndAllComponentsAsync(modules['External']).then(compiled => {
const m = compiled.ngModuleFactory.create(this.injector);
const factory = compiled.componentFactories[0];
const cmp = factory.create(this.injector, [], null, m);
});
});
Run Code Online (Sandbox Code Playgroud)
导入外部模块,不使用webpack(afaik)
const url = 'https://gist.githubusercontent.com/dianadujing/a7bbbf191349182e1d459286dba0282f/raw/c23281f8c5fabb10ab9d144489316919e4233d11/app.module.ts';
const importer = (url:any) => Observable.fromPromise(System.import(url));
console.log('importer:', …Run Code Online (Sandbox Code Playgroud) 我找到了一个很棒的教程,解释了如何使用Angular CLI设置express.js,但在本教程中,角度应用程序被编译到生产dist文件夹中:https: //scotch.io/tutorials/mean-app-with-angular- 2 -和-的棱角-CLI
如何将express.js与Angular CLI集成,但我希望express.js能够与Angular应用程序的开发版本一起使用,如果我对快速OR角度应用程序进行更改,我希望nodemon重新启动.
花了八个多小时试图让这个工作.谢谢!
每次我对Angular应用程序进行更改时都不想运行'ng build'(这需要太长时间) - 每当我将更改保存到我的角度应用程序时,我都想立即重新加载(就像我在运行'ng serve'一样) ')或表达应用程序.
我找到了一个教程,你将Angular 2 QuickStart与Express连接起来,它可以工作,但我希望使用Angular CLI.
我知道Angular CLI使用WebPack,而QuickStart使用System.js
我使用angular CLI创建了一个模块,忘记在创建时添加--routing,现在我想添加一个路由模块.
ng init --routing 在角度CLI版本1.1.1中没有帮助
我使用npm单独安装了Angular CLI包:
npm install --save-dev @angular/cli@latest
Run Code Online (Sandbox Code Playgroud)
当我尝试使用命令时,cli我收到一个错误:
Unable to find any apps in `.angular-cli.json`.
Run Code Online (Sandbox Code Playgroud)
如何.angular-cli.json为当前项目生成?
我正在转换库(ng-app-state)以使用angular cli,现在v6支持库(yay!).
在一些代码中进行脚手架和复制之后,这是我的第一个问题:
我如何/在哪里添加第三方依赖项?
到package.json,或到projects/ng-app-state/package.json?
我希望在我的Angular2应用程序上的某个地方有一个时间戳或内部版本号,这样我就可以判断用户是否使用旧的缓存版本.
如何在AOT编译/构建时使用Angular2中的AngularCLI执行此操作?
angular-cli ×10
angular ×9
angular5 ×1
angular8 ×1
express ×1
frontend ×1
javascript ×1
node.js ×1
npm ×1
npm-install ×1
polyfills ×1
webpack ×1