0

I have created Asp.Net MVC Angular2 application which is working fine while running in visual studio2017 External Host. But when i publish this application and run through IIS. i am receiving an error as

Uncaught ReferenceError: System is not defined in

  1. systemjs.config.js and
  2. _Layout.cshtml

    System.import('app').catch(function(err){ console.error(err); });

Below is my Bundle.config class:

public class BundleConfig
{
     public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                    "~/Scripts/jquery-{version}.js"));

        bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                    "~/Scripts/jquery.validate*"));

        bundles.Add(new ScriptBundle("~/bundles/angular").Include(                
                   "~/node_modules/core-js/client/shim.min.js",
                   "~/node_modules/systemjs/dist/system-polyfills.js",                                 
                   "~/node_modules/zone.js/dist/zone.js",
                   "~/node_modules/systemjs/dist/system.src.js",
                   "~/node_modules/systemjs/dist/system.js",
                   "~/systemjs.config.js"
                   ));

        bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                    "~/Scripts/modernizr-*"));

        bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(                      
                  "~/Scripts/bootstrap.min.js",                      
                  "~/Scripts/respond.js"                       
                  ));

        bundles.Add(new StyleBundle("~/Content/css").Include(
                  "~/Content/bootstrap.min.css",
                  "~/Content/font-awesome.min.css",
                  "~/Content/animate.min.css",
                  "~/node_modules/angular2-busy/build/style/busy.css",
                  "~/node_modules/ng2-toastr/bundles/ng2-toastr.min.css",
                   "~/Content/custom.css"                       
                  ));          
    }
}

systemjs.config.js

 (function (global) {
        SystemJS.config({        
        paths: {
            'npm:': 'node_modules/'
        },
        map: {
          'app': 'app',

          '@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/animations': 'npm:@angular/animations/bundles/animations.umd.js',
          '@angular/animations/browser': 'npm:@angular/animations/bundles/animations-browser.umd.js',
          '@angular/platform-browser/animations': 'npm:@angular/platform-browser/bundles/platform-browser-animations.umd.js', 
          'file-saver': 'npm:file-saver/',
          'angular2-busy': 'npm:angular2-busy',

          'ng2-smart-table': 'npm:ng2-smart-table',
          'ng2-completer': 'npm:ng2-completer',
          'ng2-bs3-modal': 'npm:/ng2-bs3-modal',
          'lodash': 'npm:lodash',
          'rxjs': 'npm:rxjs',
          'angular-in-memory-web-api': 'npm:angular-in-memory-web-api/bundles/in-memory-web-api.umd.js',
          'mydatepicker': 'npm:mydatepicker/bundles/mydatepicker.umd.min.js',
          'ng2-toastr': 'npm:ng2-toastr',

          'moment': 'npm:moment',
          'ngx-pipes': 'npm:ngx-pipes/bundles/ngx-pipes.umd.min.js'

        },
        packages: {
                app: { main: 'main.js', defaultExtension: 'js' },
                rxjs: { defaultExtension: 'js' },
                'ng2-bs3-modal': { main: '/bundles/ng2-bs3-modal.js', defaultExtension: 'js' },
                'ng2-smart-table': { main: 'bundles/table.umd.js', defaultExtension: 'js' },
                'ng2-completer': { main: 'ng2-completer.umd.js', defaultExtension: 'js' },
                'lodash': { main: 'lodash.js', defaultExtension: 'js' },
                'file-saver': { format: 'global', main: 'FileSaver.js', defaultExtension: 'js'},
                'angular2-busy': { main: './index.js', defaultExtension: 'js' },
                'moment': { main: 'moment', defaultExtension: 'js' },            
                'ng2-toastr': { main: '/bundles/ng2-toastr.min.js', defaultExtension: 'js' },     
            }
      });
    })(this);

1 Answer 1

0

I found one work around, I copied my node_modules folder from my project to the publish package and saw the error was gone

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.