2017-10-16 33 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