Search code examples
angularreduxsystemjslite-server

process is not defined in lite-server with redux


When using the default SystemJS config from Angular 2 RC.5, the lite-server throw an error of process is not defined if add redux as dependency. Has anyone experienced this? Here is the trace stack:

(index):43 Error: ReferenceError: process is not defined at Object.eval (http://localhost:3000/node_modules/redux/lib/index.js:38:5) at eval (http://localhost:3000/node_modules/redux/lib/index.js:47:4) at eval (http://localhost:3000/node_modules/redux/lib/index.js:48:3) at Object.eval (http://localhost:3000/node_modules/ng2-redux/lib/components/ng-redux.js:14:15) Evaluating http://localhost:3000/node_modules/redux/lib/index.js Evaluating http://localhost:3000/node_modules/ng2-redux/lib/components/ng-redux.js Evaluating http://localhost:3000/node_modules/ng2-redux/lib/index.js Evaluating http://localhost:3000/actions/session.actions.js Evaluating http://localhost:3000/app/app.component.js Evaluating http://localhost:3000/app/app.module.js Evaluating http://localhost:3000/app/main.js Error loading http://localhost:3000/app/main.js


Solution

  • For the Stack Overflow record, repeating my response to the same question on github: https://github.com/angular-redux/ng2-redux/issues/202

    Try putting this in system.config.js:

    var map = {
      /* ... */
      'ng2-redux': 'node_modules/ng2-redux',
      'redux':     'node_modules/redux',
    };
    
    var packages = {
      /* ... */
      'ng2-redux': { main: 'lib/index.js', defaultExtension: 'js' },
      'redux':     { main: 'dist/redux.js', defaultExtension: 'js' },
    };