我使用angular-cli创建了一个示例英雄应用程序(快速启动中的应用程序),它按预期工作.
npm start 提出我的应用程序,按预期工作.
然而,在电子中启动应用程序似乎失败了.对于我的生活似乎无法弄清楚为什么电子无法找到其中包含的文件夹dist/.
即我的dist/目录有以下内容:
但是,当我启动electron dist/(包含index.js电子主文件)时,控制台输出以下内容:
Failed to load resource: net::ERR_FILE_NOT_FOUND
file:///vendor/systemjs/dist/system.src.js Failed to load resource:
Run Code Online (Sandbox Code Playgroud)
但显然他们在vendor/目录中,因为我npm start的工作正常.
我index.js几乎是入门的副本:
const electron = require('electron');
// Module to control application life.
const {app} = electron;
// Module to create native browser window.
const {BrowserWindow} = electron;
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when …Run Code Online (Sandbox Code Playgroud) 我有一个.tsx文件并通过ts文件导入它
import {ReactChildComponentView} from "./MessageBox";
Run Code Online (Sandbox Code Playgroud)
但是当我运行服务时它会抛出一个错误
ERROR in ./src/app/react/wrapper.component.ts
Module not found: Error: Can't resolve './MessageBox' in '.../src/app/react'
Run Code Online (Sandbox Code Playgroud)
在Chrome控制台中,我可以看到以下错误
using description file: .../package.json (relative path: ./src/app/react/MessageBox)
as directory
.../src/app/react/MessageBox doesn't exist
no extension
.../src/app/react/MessageBox doesn't exist
.ts
.../src/app/react/MessageBox.ts doesn't exist
.js
.../src/app/react/MessageBox.js doesn't exist
Run Code Online (Sandbox Code Playgroud)
看起来像angular不会找.tsx文件.我怎么能改变呢?
我通过"angular-cli"版本"1.0.0-beta.28.3"创建角度2应用程序.
当我使用命令"npm start"或"ng serve"时,该应用程序正在 http:// localhost:4200上运行
但是,当更改脚本文件或CSS类型的某些代码时,浏览器的实时刷新不会发生.这有什么不对?谢谢!
我正在使用angular-CLI for angular 2,运行我在命令提示符下运行服务获取模块构建失败'无法读取所有我的角度2项目的属性newLine of undefined'错误.
Module build failed: TypeError: Cannot read property 'newLine' of undefined
at Object.getNewLineCharacter (C:\Users\timebound\angularJson\node_modules\typescript\lib\typescript.js:8062:20)
at Object.createCompilerHost (C:\Users\timebound\angularJson\node_modules\typescript\lib\typescript.js:44978:26)
at Object.ngcLoader (C:\Users\timebound\angularJson\node_modules\@ngtools\webpack\src\loader.js:329:31)
Run Code Online (Sandbox Code Playgroud)
@ multi webpack-dev-server/client?http:// localhost:4300 / ./src/main.ts
我跟着角度cli问题,仍然无法修复,我更新角2,请帮助我
我有一个main router-outlet,用于显示登录屏幕(/login)和主要内容屏幕(登录后显示)(/main).
一旦用户在内容屏幕上,我想在顶部显示导航栏,有2个选项(例如,"概述","洞察").这个导航栏是OverviewComponent和InsightsComponent
在这个导航栏下面,我想显示另一个路由器插座,它将加载OverviewComponent或InsightsComponent根据用户在导航栏中点击的内容.如果我将'/ overview'和/'insights'作为路线,它将直接显示相应的组件,但不会显示导航栏.
以下是我当前的路由配置(这不对):
const appRoutes: Routes = [
{ path: 'main', component: MainComponent},
{ path: 'overview', component: OverviewComponent},
{ path: 'insights', component: InsightsComponent },
{ path: 'login', component: LoginComponent },
{ path: '',
redirectTo: '/login',
pathMatch: 'full'
},
{ path: '**', component: PageNotFoundComponent }
];
Run Code Online (Sandbox Code Playgroud)
如果我们能够在angular2 angular4中实现这一点,请告诉我.我正在使用以下版本:
"@angular/core": "^4.0.0"
"@angular/router": "^4.0.0"
"@angular/cli": "1.0.1"
Run Code Online (Sandbox Code Playgroud)
******************尝试2 - 仍然没有工作******************
const appRoutes: Routes = [
{ path: 'main',
children: …Run Code Online (Sandbox Code Playgroud) 我将角度升级到4,角度cli升级到1.03.运行命令后,npm ls typescript我得到:
+-- @angular/cli@1.0.3
| `-- typescript@2.2.2
`-- typescript@2.2.2 invalid
npm ERR! invalid: typescript@2.2.2 C:\development\projects-git\mydoc\static-web\node_modules\typescript
Run Code Online (Sandbox Code Playgroud)
第一个和第二个打字稿之间的区别是什么,为什么第二个打字机无效/如何解决?
我认为上面的错误是我得到下面的错误的原因所以我希望有两个修复,所以我可以再次运行我的应用程序.
ERROR in AppModule is not an NgModule
ERROR in ./src/main.ts
Module build failed: TypeError: Cannot read property 'newLine' of undefined
at Object.getNewLineCharacter (..\static-web\node_modules\typescript\lib\typescript.js:9580:20)
at Object.createCompilerHost (..\static-web\node_modules\typescript\lib\typescript.js:66674:26)
at Object.ngcLoader (..\static-web\node_modules\@ngtools\webpack\src\loader.js:202:31)
@ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts
Run Code Online (Sandbox Code Playgroud) 嗨,我正在开发一个使用角度4的平均应用程序.我使用了角度cli配置.我想使用监视模式自动构建代码,并且还希望在任何文件更改时重新启动节点服务器.
我使用了以下命令但没有工作
script: {
"server": "ng build -w && nodemon --watch src/**/*.ts --exec ts-node ./bin/www"
}
Run Code Online (Sandbox Code Playgroud)
我已将配置保存在从其他位置bin/www导入的目录文件中server.ts.
上面命令的问题是,ng cli正在构建启用了watch的代码,但nodemon没有启动.
所以我尝试了以下内容.但它的建筑只有一次作为手表没有启用cli.
script: {
"server": "ng build && nodemon --watch src/**/*.ts --exec ts-node ./bin/www"
}
Run Code Online (Sandbox Code Playgroud)
在任何一种情况下,nodemon都无法工作.
我在angular 4项目中有警报服务。所有组件都可以在该服务中设置警报,但是只有一些组件可以显示警报,而每个组件都可以在唯一的位置显示警报。所以我的问题是,如何在所有html文件中定义从服务获取变量?
我的服务如下所示:
import { Injectable } from '@angular/core';
@Injectable()
export class AlertService {
message;
constructor() { }
setMessage(message){
this.message = message;
}
}
Run Code Online (Sandbox Code Playgroud)
要设置消息的组件只需导入服务并调用setMessage方法。但是当我尝试在html文件中使用消息时,例如:
{{message}}
Run Code Online (Sandbox Code Playgroud)
然后超出范围。如何使该消息在所有组件的所有html文件中均可访问?
也许有比服务变量更好的方法来解决这种需求?
我正在努力让我的构建管道启动并运行一个angular-cli应用程序.据我所知,我需要使用globaly安装angular-cli才能测试应用程序.
但是当我运行"安装Angular-CLI"步骤时,我在VSTS中收到以下错误
2017-07-23T19:10:50.7544696Z ## [section]开始:安装Angular CLI 2017-07-23T19:10:50.7674698Z ==================== ================================================== ======== 2017-07-23T19:10:50.7674698Z任务:npm 2017-07-23T19:10:50.7674698Z描述:安装和发布npm包,或运行npm命令.支持npmjs.com和经过身份验证的注册表,如包管理.2017-07-23T19:10:50.7674698Z版本:1.0.3 2017-07-23T19:10:50.7674698Z作者:Microsoft Corporation 2017-07-23T19:10:50.7674698Z帮助:更多信息 2017-07-23T19:10 :50.7674698Z ================================================= =============================== 2017-07-23T19:10:51.5557774Z ## [错误] TypeError:无法读取属性'trim'of null 2017-07-23T19:10:51.5587778Z ## [section]完成:安装Angular CLI
我输入了链接中显示的所有内容.这是某个地方的错误,还是有人知道我做错了什么?
我的应用程序中有一些繁重的javascript代码,它正在阻碍UI,使其感觉低于60fps(janky).
我想利用网络工作者而不会失去角度cli的舒适度(我不想跑ng eject).理想情况下,我的整个应用程序将在Web worker中运行.
这目前可能吗?
前提条件:
angular-cli ×10
angular ×9
javascript ×3
typescript ×3
electron ×1
express ×1
mean-stack ×1
node.js ×1
nodemon ×1
router ×1
web-worker ×1
webpack ×1