【问题标题】:npm ERR! Failed at the angular2-quickstart@1.0.0 start script 'tsc && concurrently "tsc -w" "lite-server"npm 错误!在 angular2-quickstart@1.0.0 启动脚本 'tsc && concurrently "tsc -w" "lite-server" 失败
【发布时间】:2016-11-01 21:03:56
【问题描述】:

我根据this tutorial修改了app/main.ts,当我“npm start”时出现以下错误:

这是带有提交消息error的项目文件:https://github.com/monajalal/angular2_projects

import {bootstrap}    from '@angular/platform-browser-dynamic';
import {AppComponent} from '@angular/core'

@Component({
    selector: 'my-app',
    template: '<h1>Ultra Racing</h1>'

})
class AppComponent{}
bootstrap(AppComponent);

错误:

Monas-MacBook-Pro:my-proj mona$ npm start

> angular2-quickstart@1.0.0 start /Users/mona/angular/my-proj
> tsc && concurrently "tsc -w" "lite-server" 

app/app.component.ts(5,25): error TS1005: ',' expected.
app/app.component.ts(5,27): error TS1005: ':' expected.
app/app.component.ts(5,33): error TS1005: ',' expected.
app/app.component.ts(5,41): error TS1005: ':' expected.
app/app.component.ts(5,43): error TS1005: ',' expected.
app/app.component.ts(5,47): error TS1139: Type parameter declaration expected.
app/app.component.ts(5,52): error TS1002: Unterminated string literal.
app/app.component.ts(6,1): error TS1005: ',' expected.

npm ERR! Darwin 14.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v5.8.0
npm ERR! npm  v3.8.2
npm ERR! code ELIFECYCLE
npm ERR! angular2-quickstart@1.0.0 start: `tsc && concurrently "tsc -w" "lite-server" `
npm ERR! Exit status 2
npm ERR! 
npm ERR! Failed at the angular2-quickstart@1.0.0 start script 'tsc && concurrently "tsc -w" "lite-server" '.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the angular2-quickstart package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     tsc && concurrently "tsc -w" "lite-server" 
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs angular2-quickstart
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls angular2-quickstart
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/mona/angular/my-proj/npm-debug.log

【问题讨论】:

    标签: angularjs node.js typescript angular npm


    【解决方案1】:

    在你的 main.ts 中你应该有:

    import { bootstrap }    from '@angular/platform-browser-dynamic';
    import { AppComponent } from './app.component';
    
    bootstrap(AppComponent);
    

    参考:https://angular.io/guide/quickstart

    【讨论】:

      【解决方案2】:

      我修改了app/app.component.ts: 从“@angular/core”导入{组件};

      @Component({
          selector: 'my-app',
          template: "<h1>Mona's first Angular 2 App</h1>"
      })
      export class AppComponent { }
      

      这是由于 ' 在 Mona 之后,我不得不使用 " 来修复它。这是 Angular Gitter Channel 的 Google 的“Rob Wormald”告诉我的。

      【讨论】:

      • 只是一个建议:不要使用“使用反引号`
      猜你喜欢
      • 1970-01-01
      • 2019-06-07
      • 2016-07-16
      • 2017-06-07
      • 2017-02-07
      • 2016-07-01
      • 1970-01-01
      • 2017-06-21
      • 2017-02-08
      相关资源
      最近更新 更多