2017-10-16 85 views
0

我正在使用VS 2017(ASP 5 Web Api)+ systemjs的Angular 4。 我試圖建立生產角應用,我已經添加2只依賴於 的package.json無法使用systemjs構建angular 4項目

"devDependencies": { 
    ..... 
    "gulp": "3.9.1", 
    "systemjs-builder": "0.16.11" 
    } 

我創建創建gulpfile.js在ASP項目的根文件夾

var gulp = require('gulp'), 
    Builder = require('systemjs-builder'); 


gulp.task('bundle-angular-dependencies', function() { 
    // optional constructor options 
    // sets the baseURL and loads the configuration file 
    var builder = new Builder('', 'systemjs.config.js'); 

    return builder 
    .bundle('app/boot.js - [app/**/*.js]', 'path/to/put/angular.bundle.js', { minify: true}) 
    .then(function() { 
     console.log('Build complete'); 
    }) 
    .catch(function(err) { 
     console.log('Build error'); 
     console.log(err); 
    }); 
}); 

然後在項目的根文件夾我已經運行:

gulp bundle-angular-dependencies 

,並得到

Build error 
Error: Unable to calculate canonical name to bundle file:///app/boot.js. Ensure that this module sits within the baseURL or a wildcard path config. 
    at getCanonicalNamePlain (D:\myapp\node_modules\systemjs-builder\lib\utils.js:227:13) 
    at getCanonicalName (D:\myapp\node_modules\systemjs-builder\lib\utils.js:150:19) 
    at D:\myapp\node_modules\systemjs-builder\lib\arithmetic.js:171:38 
    at <anonymous> 
[18:50:43] Finished 'bundle-angular-dependencies' after 604 ms 

感謝您的幫助

回答

1

爲什麼不使用的Visual Studio 2017年新的內置角模板?

文件|新增|項目

選擇在「新核心ASP.NET Web應用程序」對話框中的ASP.NET核心Web應用程序模板

然後,選擇角度。

enter image description here

+0

德博拉嗨,我沒有使用ASP的核心,我使用ASP 5.I認爲不會work.thanks – mrapi

+1

你見過這樣的:https://www.hanselman.com/博客/ ASPNET5IsDeadIntroducingASPNETCore10AndNETCore10.aspx ASP.NET 5 *是* Asp.NET核心。 – DeborahK

+0

我知道,但我的db提供者現在不完全支持Core.thanks – mrapi