【问题标题】:Angular 2 use the source code in your projectAngular 2 在你的项目中使用源代码
【发布时间】:2016-12-13 19:47:36
【问题描述】:

我正在使用 npm 安装 Angular:

npm install @angular...

问题是打字稿源文件不包括在那里。我希望能够使用打字稿源文件(使用源映射)调试代码。 例如克隆 repo 并使用此代码。有办法吗?

【问题讨论】:

    标签: javascript debugging angular npm


    【解决方案1】:

    npm 注册表中没有包“@angular”。请参阅angular quickstart guide。用这个更新你的 package.json(这是所有 @angular 依赖项),然后 npm install 会给你打字稿。

        "dependencies": {
        "@angular/common": "~2.3.0",
        "@angular/compiler": "~2.3.0",
        "@angular/core": "~2.3.0",
        "@angular/forms": "~2.3.0",
        "@angular/http": "~2.3.0",
        "@angular/platform-browser": "~2.3.0",
        "@angular/platform-browser-dynamic": "~2.3.0",
        "@angular/router": "~3.3.0",
    
        "angular-in-memory-web-api": "~0.2.0",
        "systemjs": "0.19.40",
        "core-js": "^2.4.1",
        "reflect-metadata": "^0.1.8",
        "rxjs": "5.0.0-rc.4",
        "zone.js": "^0.7.2"
      }
    

    别忘了在系统js中设置映射

    map: {
          '@angular/core': 'npm:@angular/core/bundles/core.umd.js',
          '@angular/common': 'npm:@angular/common/bundles/common.umd.js',
          '@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
          '@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
          '@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
          '@angular/http': 'npm:@angular/http/bundles/http.umd.js',
          '@angular/router': 'npm:@angular/router/bundles/router.umd.js',
          '@angular/forms': 'npm:@angular/forms/bundles/forms.umd.js',
          'rxjs': 'npm:rxjs',
        }
    

    【讨论】:

    • 您能解释一下为什么您的解决方案与 npm 不同吗?
    • npm 注册表中没有包'@angular',它不应该安装任何东西。
    猜你喜欢
    • 1970-01-01
    • 2023-04-01
    • 2023-03-29
    • 1970-01-01
    • 1970-01-01
    • 2019-02-22
    • 2017-02-25
    • 1970-01-01
    • 2015-05-29
    相关资源
    最近更新 更多