【问题标题】:Angular2 Showing error when tried to start the project?Angular2尝试启动项目时显示错误?
【发布时间】:2016-12-16 22:01:49
【问题描述】:

我不知道为什么会发生这个错误。我的项目早些时候运行良好,我已经在项目目录之外全局安装了一些包(如 gulp 和 yo 生成器)。当我停止我的项目并重新启动它时,它显示以下错误。节点服务器仍在运行,但是当我使用 npm run tsc: -w 时,终端中会出现以下错误。

我使用 npm start,它是 package.json 中的一个脚本:

"start": "tsc && concurrently \"npm run tsc:w\" \"node server/index.js\" ",

../app/app.ts(11,5): error TS2345: Argument of type '{ selector: string; viewBindings: typeof NamesList[]; }' is not assignable to parameter of type '{ selector?: string; properties?: List<string>; events?: List<string>; host?: StringMap<string, s...'.
      Object literal may only specify known properties, and 'viewBindings' does not exist in type '{ selector?: string; properties?: List<string>; events?: List<string>; host?: StringMap<string, s...'.
    ../app/app.ts(17,2): error TS2345: Argument of type 'typeof App' is not assignable to parameter of type 'Type'.
      Type 'App' is not assignable to type 'Type'.
        Property 'apply' is missing in type 'App'.
    ../app/components/about/about.ts(5,2): error TS2345: Argument of type 'typeof About' is not assignable to parameter of type 'Type'.
      Type 'About' is not assignable to type 'Type'.
        Property 'apply' is missing in type 'About'.
    ../app/components/about/about.ts(8,2): error TS2345: Argument of type 'typeof About' is not assignable to parameter of type 'Type'.
    ../app/components/home/home.ts(4,2): error TS2345: Argument of type 'typeof Home' is not assignable to parameter of type 'Type'.
      Type 'Home' is not assignable to type 'Type'.
        Property 'apply' is missing in type 'Home'.
    ../app/components/home/home.ts(7,2): error TS2345: Argument of type 'typeof Home' is not assignable to parameter of type 'Type'.
    ../node_modules/angular2/src/change_detection/parser/parser.d.ts(21,12): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/change_detection/parser/parser.d.ts(23,18): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/change_detection/parser/parser.d.ts(25,17): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/change_detection/parser/parser.d.ts(27,29): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/change_detection/parser/parser.d.ts(30,27): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/change_detection/parser/parser.d.ts(49,37): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/change_detection/parser/parser.d.ts(60,36): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/core/compiler/element_binder.d.ts(6,12): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/core/compiler/element_binder.d.ts(8,23): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/core/compiler/element_binder.d.ts(13,24): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/core/compiler/element_binder.d.ts(13,70): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/core/compiler/element_injector.d.ts(98,12): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/core/compiler/element_injector.d.ts(112,54): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/core/compiler/query_list.d.ts(22,6): error TS2304: Cannot find name 'Symbol'.
    ../node_modules/angular2/src/core/compiler/view.d.ts(69,81): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/core/compiler/view.d.ts(97,58): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/core/compiler/view.d.ts(111,104): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/core/zone/ng_zone.d.ts(2,37): error TS2304: Cannot find name 'Zone'.
    ../node_modules/angular2/src/di/injector.d.ts(1,1): error TS2654: Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition.
    ../node_modules/angular2/src/di/injector.d.ts(1,1): error TS6053: File '/home/angular2/typings/es6-promise/es6-promise.d.ts' not found.
    ../node_modules/angular2/src/facade/async.d.ts(1,1): error TS2654: Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition.
    ../node_modules/angular2/src/facade/async.d.ts(1,1): error TS6053: File '/home/angular2/typings/es6-promise/es6-promise.d.ts' not found.
    ../node_modules/angular2/src/facade/async.d.ts(2,1): error TS6053: File '/home/angular2/typings/rx/rx.d.ts' not found.
    ../node_modules/angular2/src/facade/async.d.ts(4,10): error TS2661: Cannot re-export name that is not defined in the module.
    ../node_modules/angular2/src/facade/async.d.ts(20,45): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/facade/async.d.ts(20,51): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/facade/async.d.ts(21,29): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/facade/async.d.ts(22,46): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/facade/async.d.ts(22,52): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/facade/async.d.ts(23,30): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/facade/lang.d.ts(1,1): error TS2654: Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition.
    ../node_modules/angular2/src/facade/lang.d.ts(1,1): error TS6053: File '/home/angular2/globals.d.ts' not found.
    ../node_modules/angular2/src/facade/lang.d.ts(2,22): error TS2304: Cannot find name 'BrowserNodeGlobal'.
    ../node_modules/angular2/src/facade/lang.d.ts(31,43): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/facade/lang.d.ts(31,49): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/facade/lang.d.ts(47,50): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/facade/lang.d.ts(48,63): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/facade/lang.d.ts(50,31): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/facade/lang.d.ts(51,41): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/facade/lang.d.ts(59,40): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/facade/lang.d.ts(59,51): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/facade/lang.d.ts(62,43): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/facade/lang.d.ts(77,47): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/facade/lang.d.ts(79,45): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/facade/lang.d.ts(80,42): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/facade/lang.d.ts(80,48): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/facade/lang.d.ts(116,25): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/facade/lang.d.ts(116,38): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/facade/lang.d.ts(116,49): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/facade/lang.d.ts(116,61): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/facade/lang.d.ts(116,76): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/facade/lang.d.ts(116,91): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/facade/lang.d.ts(116,111): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/facade/lang.d.ts(117,27): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/facade/lang.d.ts(118,34): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/http/enums.d.ts(46,23): error TS2304: Cannot find name 'int'.
    ../node_modules/angular2/src/http/interfaces.d.ts(1,1): error TS2654: Exported external package typings file cannot contain tripleslash references. Please contact the package author to update the package definition.
    ../node_modules/angular2/src/http/interfaces.d.ts(1,1): error TS6053: File '/home/angular2/typings/rx/rx.d.ts' not found.
    ../node_modules/angular2/src/profile/profile.d.ts(1,28): error TS2307: Cannot find module './wtf_impl'.
    ../node_modules/angular2/src/profile/profile.d.ts(2,23): error TS2307: Cannot find module './wtf_impl'.
    ../node_modules/angular2/src/render/dom/view/shared_styles_host.d.ts(3,27): error TS2304: Cannot find name 'Set'.
    ../node_modules/angular2/src/router/instruction.d.ts(1,32): error TS2307: Cannot find module './path_recognizer'.
    ../node_modules/angular2/src/router/route_recognizer.d.ts(1,32): error TS2307: Cannot find module './path_recognizer'.
    6:45:32 PM - Compilation complete. Watching for file changes.

【问题讨论】:

    标签: angular typescript package.json


    【解决方案1】:

    您是否正确安装了类型?

    1. 通过 npm 全局安装 - $ npm install typings --global
    2. 然后在项目上 - $ typings install

      此外,如果您在防火墙后面,则需要将 .typingssrc 文件添加到项目根目录 - 项目安装的类型也需要离开防火墙,并且不能使用 npm 代理设置.

    .typingssrc(文件名) { "proxy" : "http:// 添加你的代理服务器> /", “拒绝未授权”:假 }

    【讨论】:

      【解决方案2】:

      使用npm i安装所有节点模块。为此,您需要在您的机器中安装nodejs。要检查您的机器中是否有节点,请使用node -v命令

      【讨论】:

        猜你喜欢
        • 2020-12-26
        • 2022-06-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-01-10
        • 2020-09-12
        • 1970-01-01
        • 2020-06-13
        相关资源
        最近更新 更多