2016-10-17 20 views
0

我有一个.net Wepapi项目作为后端和用Angular2编写的前端都包含在一个Visual Studio解决方案。 本地构建工作正常,但如果我使用我的CD管道中的TFS Online构建构建它,则构建失败。我recive以下错误:Angular2代码抛出一个错误与TFS生成

Build: Cannot find module '@angular/core'.

和其他一些这样的。

这是我的package.json文件

{ 
    "name": "emersy", 
    "version": "1.0.0", 
    "scripts": { 
    "start": "concurrently \"npm run tsc:w\" \"npm run lite\" ", 
    "tsc": "tsc", 
    "tsc:w": "tsc -w", 
    "lite": "lite-server", 
    "typings": "typings", 
    "postinstall": "typings install" 
    }, 
    "license": "ISC", 
    "dependencies": { 
    "@angular/common": "~2.1.0", 
    "@angular/compiler": "~2.1.0", 
    "@angular/core": "~2.1.0", 
    "@angular/forms": "~2.1.0", 
    "@angular/http": "~2.1.0", 
    "@angular/platform-browser": "~2.1.0", 
    "@angular/platform-browser-dynamic": "~2.1.0", 
    "@angular/router": "~3.1.0", 
    "@angular/upgrade": "~2.1.0", 
    "bootstrap": "^3.3.7", 
    "core-js": "^2.4.1", 
    "jquery": "^2.2.3", 
    "reflect-metadata": "^0.1.8", 
    "rxjs": "5.0.0-beta.12", 
    "systemjs": "0.19.39", 
    "zone.js": "^0.6.25" 
    }, 
    "devDependencies": { 
    "concurrently": "^3.0.0", 
    "lite-server": "^2.2.2", 
    "typescript": "^2.0.3", 
    "typings": "^1.4.0" 
    } 
} 

这是我的分型

{ 
    "globalDependencies": { 
    "core-js": "registry:dt/core-js#0.0.0+20160725163759", 
    "jasmine": "registry:dt/jasmine#2.2.0+20160621224255", 
    "node": "registry:dt/node#6.0.0+20160909174046" 
    } 
} 

,这我tsconfig

{ 
    "compileOnSave": true, 
    "compilerOptions": { 
    "target": "es5", 
    "module": "commonjs", 
    "moduleResolution": "node", 
    "sourceMap": true, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "removeComments": false, 
    "noImplicitAny": true 
    } 
} 

注:我使用XAML构建,而不是新的建设发动机。

这里我systems.js.config

(function (global) { 
    System.config({ 
     transpiler: 'ts', 
     typescriptOptions: { 
      tsconfig: true 
     }, 
     meta: { 
      'typescript': { 
       "exports": "ts" 
      } 
     }, 
     paths: { 
      // paths serve as alias 
      'npm:': 'https://unpkg.com/' 
     }, 
     // map tells the System loader where to look for things 
     map: { 
      // our app is within the app folder 
      app: 'app', 

      // angular bundles 
      '@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', 
      '@angular/upgrade': 'npm:@angular/upgrade/bundles/upgrade.umd.js', 

      // other libraries 
      'rxjs': 'npm:rxjs', 
      'ts': 'npm:[email protected]/lib/plugin.js', 
      'typescript': 'npm:[email protected]/lib/typescript.js', 

     }, 
     // packages tells the System loader how to load when no filename and/or no extension 
     packages: { 
      app: { 
       main: './main.ts', 
       defaultExtension: 'ts' 
      }, 
      rxjs: { 
       defaultExtension: 'js' 
      } 
     } 
    }); 
})(this); 

EDIT1: 迁移构建中vnext构建之后现在的工作的,并没有给出一个生成错误。现在我已经在构建步骤中将该部署添加到我的天蓝应用程序中。该应用程序下降了天蓝色的应用程序,但我的角码不起作用。 我得到这个错误:

mysite.azurewebsites.net/:38 Error: (SystemJS) Unexpected token < 
    SyntaxError: Unexpected token < 
    Evaluating http://mysite.azurewebsites.net/app/main.ts 
    Error loading http://mysite.azurewebsites.net/app/main.ts 

看起来就是不应对NPM模块

这是我的构建配置 enter image description here

编辑2: enter image description here

​​

编辑3: 的MSBuild参数

/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation=$(build.stagingDirectory) 

enter image description here

+0

将有助于了解如何构建失败。也许有错误信息? –

+0

哦,对不起,你是对的:-)建立:找不到模块'@角/核心'。也添加到上面的帖子 – cpiock

+0

你如何在你的页面上加载你的角度应用程序? System.Import?如果是这样,你的systemjs.config文件是什么样子的? – AntonJ

回答

0

迁移构建中vnext构建之后现在的工作的,并没有给出一个生成错误。现在我已经在构建步骤中将该部署添加到我的天蓝应用程序中。该应用程序下降了天蓝色的应用程序,但我的角码不起作用。 我得到这个错误:

mysite.azurewebsites.net/:38 Error: (SystemJS) Unexpected token < 
    SyntaxError: Unexpected token < 
    Evaluating http://mysite.azurewebsites.net/app/main.ts 
    Error loading http://mysite.azurewebsites.net/app/main.ts 

看起来就是不应对NPM模块

这是我的构建配置 enter image description here

+0

您可以将新问题添加到原始帖子或创建这个问题的新线索。这个问题或问题不应该在答案中。另外,对于这个问题,您可以提供npm install的详细信息,构建解决方案的副本和发布构建工件步骤。 –

+0

本文可能会对您有所帮助:https://azure.microsoft.com/zh-CN/documentation/articles/nodejs-use-node-modules-azure-apps/ –

+0

将全部内容添加到第一篇文章中。我应该在npm任务中做这个吗? npm run typings install – cpiock