标签: angular-cli

使用@angular/cli 构建 chrome 扩展弹出窗口、选项和背景

我想创建一个带有弹出窗口、选项页面和后台进程的 chrome 扩展。所以基本上是一个带有 popup.html、options.html 和 background.html 页面的角度应用程序。角度cli可以做到这一点吗?

今天我可以为每个页面使用多个 webpack 配置来做到这一点,并且它可以工作。现在我想用 angular-cli 替换它。任何人都可以指出我正确的方向,即种子项目或入门示例

谢谢

google-chrome-extension angular-cli angular

1
推荐指数
2
解决办法
1332
查看次数

Angular Cli - SyntaxError: 'import' 和 'export' 可能只与 'sourceType: module' 一起出现

我正在尝试使用 angular cli 生成覆盖率报告。但是我不断收到以下错误。我不太确定这是 cli 错误还是 Karma.conf 的问题?ng test/npm test运行良好... 所以与代码覆盖选项有关吗?

    Error: Module build failed: SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' (3:0)
        at Parser.pp$5.raise (C:\Development\source\\node_modules\babylon\lib\index.js:4443:13)
        at Parser.pp$1.parseStatement (C:\Development\source\\node_modules\babylon\lib\index.js:1875:16)
        at Parser.parseStatement (C:\Development\source\\node_modules\babylon\lib\index.js:5795:22)
        at Parser.pp$1.parseBlockBody (C:\Development\source\\node_modules\babylon\lib\index.js:2262:21)
        at Parser.pp$1.parseTopLevel (C:\Development\source\\node_modules\babylon\lib\index.js:1772:8)
        at Parser.parse (C:\Development\source\\node_modules\babylon\lib\index.js:1667:17)
        at Object.parse (C:\Development\source\\node_modules\babylon\lib\index.js:7163:37)
        at Instrumenter.instrumentSync (C:\Development\source\\node_modules\istanbul-lib-instrument\dist\instrumenter.js:121:31)
        at Instrumenter.instrument (C:\Development\source\\node_modules\istanbul-lib-instrument\dist\instrumenter.js:176:32)
        at Object.module.exports (C:\Development\source\\node_modules\istanbul-instrumenter-loader\index.js:25:25),Module build failed: SyntaxError: 'import
    ' and 'export' may appear only with 'sourceType: module' (2:0)
        at Parser.pp$5.raise (C:\Development\source\\node_modules\babylon\lib\index.js:4443:13)
        at Parser.pp$1.parseStatement (C:\Development\source\\node_modules\babylon\lib\index.js:1875:16) …
Run Code Online (Sandbox Code Playgroud)

code-coverage typescript karma-jasmine angular-cli angular

1
推荐指数
1
解决办法
1011
查看次数

未找到类型

我刚刚更新了 angular-cli (v1.1) 并使用ng new MyProj. 然后我在project.json文件中添加并安装了两个依赖项:

"dependencies": {
    ...
    "toastr": "2.1.2",
    "spin": "0.0.1"
  },
  "devDependencies": {
    ...
    "@types/toastr": "2.1.32",
    "@types/spin": "2.3.30",
    ...
    "typescript": "~2.3.3"
  }
Run Code Online (Sandbox Code Playgroud)

然后我更新了自动生成的 app.component.ts 添加这个构造函数:

constructor() {
    toastr.success('Hi')
}
Run Code Online (Sandbox Code Playgroud)

IDE(视觉工作室代码)不返回任何错误,但是当我使用应用程序提供服务时,ng serve出现以下错误:

../A/src/app/app.component.ts (15,5) 中的错误:C 找不到名称“toastr”。

我真的无法弄清楚这有什么问题。

非常感谢

typescript angular-cli angular

1
推荐指数
1
解决办法
4356
查看次数

bash: npm: 命令未找到

当我检查节点的版本时,它说

v8.0.0
Run Code Online (Sandbox Code Playgroud)

但是当我检查 NPM 的版本时,它说

bash: npm: command not found
Run Code Online (Sandbox Code Playgroud)

以前,我的操作是

npm install -g "@angular/cli"

那是它始终显示npm: command not found消息的时候。

我尝试寻找可能的解决方案,但没有一个像brew和其他人那样有效。

node.js npm angular-cli angular

1
推荐指数
1
解决办法
1万
查看次数

运行ng test时在项目中找不到配置

我刚刚升级到Angular 6,但是现在我们的Jenkins构建失败了。

它正在运行以下命令:

ng test -c karma.conf.cli.js
Run Code Online (Sandbox Code Playgroud)

但是错误是:

在项目“ projectname”中找不到配置“ karma.conf.cli.js”

但是,相关文件存在于项目的根目录中。该命令在Angular 5上运行良好。谢谢

仅供参考,我可以通过在生成服务器上运行相同的命令来重现该错误。我们还刚刚将Node.js升级到v8.11.2(最新的LTS)

node.js karma-runner angular-cli angular angular6

1
推荐指数
1
解决办法
3464
查看次数

您的全局Angular CLI版本(6.0.8)大于本地版本(1.0.2)

C:\dev\myApp> ng serve -o 
Your global Angular CLI version (6.0.8) is greater than your local version (1.0.2). 
The local Angular CLI version is used.
To disable this warning use `"ng config -g cli.warnings.versionMismatch false"`
Run Code Online (Sandbox Code Playgroud)

我不知道该怎么办。

我尝试卸载angular / cli和npm cache clean, 但是仍然有问题。

有人帮我!

node.js angular-cli angular angular6 angular-cli-v6

1
推荐指数
2
解决办法
2万
查看次数

Angular 6错误:CSSSyntaxError-编译失败

描述

我在为“ background”属性提及的url()中收到相对路径错误。

当我使用绝对路径时,似乎工作正常。

错误信息

ERROR in ./src/styles.scss (./node_modules/raw-loader!./node_modules/postcss-loader/lib??embedded!./node_modules/sass-loader/lib/loader.js??ref--15-3!./src/styles.scss)
Module Error (from ./node_modules/postcss-loader/lib/index.js):
(Emitted value instead of an instance of Error) CssSyntaxError: /home/nithinchandranp/workspace/nithin-portfolio/src/scss/_config.scss:12:24: Can't resolve '../assets/img/DSC_0291.JPG' in '/home/nithinchandranp/workspace/nithin-portfolio/src'
Run Code Online (Sandbox Code Playgroud)
   @if $show-home-image{
       &#bg-img{
         background: url(../assets/img/DSC_0291.JPG);
                    ^
          background-attachment: fixed;
          //background-size: cover;
Run Code Online (Sandbox Code Playgroud)

_config.scss

$primary-color:grey;
$show-home-image:true;
//$home-image: url('/src/assets/img/DSC_0291.JPG');
$background-opacity: 0.8;
$overlay-color:black;
$secondary-color:#eece1a;


@mixin background {
    @if $show-home-image{
        &#bg-img{
            background: url(../assets/img/DSC_0291.JPG);  
            background-attachment: fixed;
            //background-size: cover; 


        &:after {
            content: '';
            position: fixed;
            top: 0;
            right: 0;
            width: 100%;
            height: 100%;
            z-index: -1;
            background: rgba($overlay-color,$background-opacity);

        }
        }
    } …
Run Code Online (Sandbox Code Playgroud)

url assets angular-cli angular angular6

1
推荐指数
1
解决办法
4510
查看次数

TS2334"对象"类型上不存在属性"长度".仅限应用启动(ng-serve)

当我启动我的角度应用程序时,我遇到了问题.

我有一个执行发布请求的函数,将一些数据返回到我的组件并绘制图表.它在我启动应用程序后做了一些随机修改并保存,但是当我第一次启动应用程序时,我得到Property 'length' does not exist on type 'Object'. 了一个for循环,我在我的响应数组上.

我已经尝试迭代响应,只有它不是null,但这不起作用.

功能:

dailyForecast() {
  var token = {token : "0a1b2c3d"};
  return this._http.post("https://www.improving.com.br/api/test/hits-by-browser", token)
  .map(result => result);
}
Run Code Online (Sandbox Code Playgroud)

我在这个for循环中得到了错误,但是在我重新编译之后它工作正常.

ngOnInit() {
  let chart = < any > {};
  this._weather.dailyForecast()
    .subscribe(res => {
      console.log(res);
      let browsers = [];
      let browsersAcesss = [];
      if (res !== null) {
        for (var i = 0; i < res.length; i++) {
          browsers.push(res[i][0]);
          browsersAcesss.push(res[i][1]);
        }
      }
    });
}
Run Code Online (Sandbox Code Playgroud)

javascript typescript angular-cli angular

1
推荐指数
1
解决办法
1809
查看次数

使用ng-new,我收到“示意图输入未针对Schema进行验证”的信息:

我收到以下错误,

$ ng new ng_api_browser

Schematic input does not validate against the Schema: {"name":"ng_api_browser","version":"7.3.1","routing":true,"style":"sass"}
Errors:

  Data path ".name" should match format "html-selector".
Run Code Online (Sandbox Code Playgroud)

如何解决此错误?

angular-cli angular angular7

1
推荐指数
1
解决办法
227
查看次数

Angular prod build error in Cannot assign to a reference or variable

I can't build prod version of my angular app.

And have only this message in IDE console:

ERROR in Cannot assign to a reference or variable!

So I can build only if add these options:

--aot=false --buildOptimizer=false
Run Code Online (Sandbox Code Playgroud)

But, even with these options app fails after deploy with this message in browser console:

ERROR TypeError: Cannot read property 'init' of undefined

which can be fixed by adding one more option:

--optimization=false 
Run Code Online (Sandbox Code Playgroud)

When I try to build with

npm run ng build …
Run Code Online (Sandbox Code Playgroud)

npm typescript angular-cli angular

1
推荐指数
1
解决办法
391
查看次数