angular-cli: ng serve -prod fails (beta 4)

Please provide us with the following information:

  1. OS? Windows 7, 8 or 10. Linux (which distribution). Mac OSX (Yosemite? El Capitan?)

Mac OS X 10.11.4 (El Cap)

  1. Versions. Please run ng --version.

angular-cli: 1.0.0-beta.4 node: 4.4.1 os: darwin x64

  1. Repro steps. Was this an app that wasn’t created using the CLI? What change did you do on your code? etc.
    1. ng new ngclitest
    2. cd ngclitest
    3. ng serve works, yeah!
    4. ng serve -prod fails, boo

Zero code changes.

  1. The log given by the failure. Normally this include a stack trace and some more information.
$ ng serve -prod
Livereload server on http://localhost:49154
Serving on http://localhost:4200/
The Broccoli Plugin: [BundlePlugin] failed with:
Error: Error on fetch for main.js at file:///Users/bbohling/Projects/Testing/ngclitest/tmp/bundle_plugin-input_base_path-gBkw51Lq.tmp/0/main.js
    ENOENT: no such file or directory, open '/Users/bbohling/Projects/Testing/ngclitest/tmp/bundle_plugin-input_base_path-gBkw51Lq.tmp/0/Users/bbohling/Projects/Testing/ngclitest/tmp/broccoli_type_script_compiler-input_base_path-tZonLqxE.tmp/0/main.js.map'
    at Error (native)
    at /Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/systemjs-builder/lib/builder.js:209:32
    at SystemJSNodeLoader.loader.fetch (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/systemjs-builder/lib/builder.js:194:6)
    at /Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/systemjs-builder/lib/trace.js:425:23
    at /Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/systemjs-builder/lib/trace.js:418:8
    at /Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/systemjs-builder/lib/trace.js:388:6
    at processImmediate [as _immediateCallback] (timers.js:383:17)
    at Trace.getLoadRecord (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/systemjs-builder/lib/trace.js:131:4)
    at Trace.getAllLoadRecords (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/systemjs-builder/lib/trace.js:552:15)
    at /Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/systemjs-builder/lib/trace.js:54:19
    at Trace.traceCanonical (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/systemjs-builder/lib/trace.js:52:4)
    at /Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/systemjs-builder/lib/arithmetic.js:243:35
    at /Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/systemjs-builder/lib/arithmetic.js:232:20
    at Array.reduce (native)
    at processExpandedOperations (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/systemjs-builder/lib/arithmetic.js:231:35)
    at exports.traceExpression (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/systemjs-builder/lib/arithmetic.js:229:8)
    at /Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/systemjs-builder/lib/builder.js:636:14
    at /Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/systemjs-builder/lib/builder.js:635:6
    at processImmediate [as _immediateCallback] (timers.js:383:17)
    at Builder.bundle (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/systemjs-builder/lib/builder.js:627:4)
    at BundlePlugin.build (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/lib/broccoli/angular-broccoli-bundle.js:19:20)
    at /Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/broccoli-caching-writer/index.js:152:21
    at lib$rsvp$$internal$$tryCatch (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/broccoli-caching-writer/node_modules/rsvp/dist/rsvp.js:1036:16)
    at lib$rsvp$$internal$$invokeCallback (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/broccoli-caching-writer/node_modules/rsvp/dist/rsvp.js:1048:17)
    at lib$rsvp$$internal$$publish (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/broccoli-caching-writer/node_modules/rsvp/dist/rsvp.js:1019:11)
    at lib$rsvp$asap$$flush (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/broccoli-caching-writer/node_modules/rsvp/dist/rsvp.js:1198:9)
    at nextTickCallbackWith0Args (node.js:420:9)
    at process._tickCallback (node.js:349:13)
From previous event:
    at /Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/systemjs-builder/lib/trace.js:483:13
From previous event:
    at /Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/systemjs-builder/lib/trace.js:388:6
    at processImmediate [as _immediateCallback] (timers.js:383:17)
From previous event:
    at Trace.getLoadRecord (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/systemjs-builder/lib/trace.js:131:4)
    at Trace.getAllLoadRecords (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/systemjs-builder/lib/trace.js:552:15)
    at /Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/systemjs-builder/lib/trace.js:54:19
From previous event:
    at Trace.traceCanonical (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/systemjs-builder/lib/trace.js:52:4)
    at /Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/systemjs-builder/lib/arithmetic.js:243:35
From previous event:
    at /Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/systemjs-builder/lib/arithmetic.js:232:20
    at Array.reduce (native)
    at processExpandedOperations (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/systemjs-builder/lib/arithmetic.js:231:35)
From previous event:
    at exports.traceExpression (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/systemjs-builder/lib/arithmetic.js:229:8)
    at /Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/systemjs-builder/lib/builder.js:636:14
From previous event:
    at /Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/systemjs-builder/lib/builder.js:635:6
    at processImmediate [as _immediateCallback] (timers.js:383:17)
From previous event:
    at Builder.bundle (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/systemjs-builder/lib/builder.js:627:4)
    at BundlePlugin.build (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/lib/broccoli/angular-broccoli-bundle.js:19:20)
    at /Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/broccoli-caching-writer/index.js:152:21
    at lib$rsvp$$internal$$tryCatch (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/broccoli-caching-writer/node_modules/rsvp/dist/rsvp.js:1036:16)
    at lib$rsvp$$internal$$invokeCallback (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/broccoli-caching-writer/node_modules/rsvp/dist/rsvp.js:1048:17)
    at lib$rsvp$$internal$$publish (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/broccoli-caching-writer/node_modules/rsvp/dist/rsvp.js:1019:11)
    at lib$rsvp$asap$$flush (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/broccoli-caching-writer/node_modules/rsvp/dist/rsvp.js:1198:9)
    at nextTickCallbackWith0Args (node.js:420:9)
    at process._tickCallback (node.js:349:13)

The broccoli plugin was instantiated at:
    at BundlePlugin.Plugin (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/broccoli-caching-writer/node_modules/broccoli-plugin/index.js:10:31)
    at BundlePlugin.CachingWriter [as constructor] (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/broccoli-caching-writer/index.js:21:10)
    at BundlePlugin (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/lib/broccoli/angular-broccoli-bundle.js:11:10)
    at Angular2App._getBundleTree (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/lib/broccoli/angular2-app.js:424:22)
    at Angular2App._buildTree (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/lib/broccoli/angular2-app.js:159:21)
    at new Angular2App (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/lib/broccoli/angular2-app.js:53:23)
    at module.exports (/Users/bbohling/Projects/Testing/ngclitest/angular-cli-build.js:6:10)
    at Class.module.exports.Task.extend.setupBroccoliBuilder (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/angular-cli/lib/models/builder.js:55:19)
    at Class.module.exports.Task.extend.init (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/angular-cli/lib/models/builder.js:89:10)
    at new Class (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/angular-cli/node_modules/core-object/core-object.js:18:12)
    at Class.module.exports.Task.extend.run (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/angular-cli/lib/tasks/serve.js:15:19)
    at /Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/angular-cli/lib/commands/serve.js:64:24
    at lib$rsvp$$internal$$tryCatch (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/angular-cli/node_modules/rsvp/dist/rsvp.js:1036:16)
    at lib$rsvp$$internal$$invokeCallback (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/angular-cli/node_modules/rsvp/dist/rsvp.js:1048:17)
    at /Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/angular-cli/node_modules/rsvp/dist/rsvp.js:331:11
    at lib$rsvp$asap$$flush (/Users/bbohling/Projects/Testing/ngclitest/node_modules/angular-cli/node_modules/angular-cli/node_modules/rsvp/dist/rsvp.js:1198:9)
  1. Mention any other details that might be useful.

Was able to reproduce more than once. ng build -prod fails too with same error.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 3
  • Comments: 22 (6 by maintainers)

Most upvoted comments

Have the same problem under Win1064 with rc1

angular-cli: 1.0.0-beta.5 node: 4.4.3 os: win32 x64

  • ng init a fresh repo
  • ng serve works *ng serve -prod produces

Error on fetch for main.js at file:///C:/Users/myname/Desktop/dsad/tmp/bundle_plugin-input_base_path-QFRZngT2.tmp/0/main.js Error: ENOENT: no such file or directory, open 'C:\Users\mham\Desktop\dsad\tmp\bundle_plugin-input_base_path-QFRZngT2.tmp\0\C:\Users\myname\Desktop\dsad\tmp\broccoli_type_script_compiler-input_base_path-RsfW9bEa.tmp\0\main.js.map' at Error (native)

@filipesilva OK I’ve managed to get it to build without errors but when I build with -prod the angular2-google-maps isn’t in the vendor directory so I can’t reference it from my index.html as per the docs for maps i.e <script src="vendor/angular2-google-maps/bundles/angular2-google-maps.js"></script>

/* global require, module */

var Angular2App = require('angular-cli/lib/broccoli/angular2-app');

module.exports = function(defaults) {
  return new Angular2App(defaults, {
    vendorNpmFiles: [
      'systemjs/dist/system-polyfills.js',
      'systemjs/dist/system.src.js',
      'zone.js/dist/**/*.+(js|js.map)',
      'es6-shim/es6-shim.js',
      'reflect-metadata/**/*.+(js|js.map)',
      'rxjs/**/*.+(js|js.map)',
      '@angular/**/*.+(js|js.map)',
      'angular2-google-maps/**/*.+(js|js.map)',
      'angular2-cookie/**/*.+(js|js.map)',
      'autolinker/**/*.+(js|js.map)'
    ]
  });
};
/***********************************************************************************************
 * User Configuration.
 **********************************************************************************************/
/** Map relative paths to URLs. */
const map: any = {
  'angular2-cookie': 'vendor/angular2-cookie',
  'angular2-google-maps': 'vendor/angular2-google-maps',
  'autolinker': 'vendor/autolinker/dist/Autolinker.js'
};

/** User packages configuration. */
const packages: any = {
  'angular2-cookie': { main: 'core.js', defaultExtension: 'js' },
  'angular2-google-maps': { defaultExtension: 'js' },
  'autolinker': {  defaultExtension: 'js' }
};

////////////////////////////////////////////////////////////////////////////////////////////////
/***********************************************************************************************
 * Everything underneath this line is managed by the CLI.
 **********************************************************************************************/
const barrels: string[] = [
  // Angular specific barrels.
  '@angular/core',
  '@angular/common',
  '@angular/compiler',
  '@angular/http',
  '@angular/router',
  '@angular/platform-browser',
  '@angular/platform-browser-dynamic',

  // Thirdparty barrels.
  'rxjs',

  // App specific barrels.
  'app',
  'app/shared',
  /** @cli-barrel */
];

const cliSystemConfigPackages: any = {};
barrels.forEach((barrelName: string) => {
  cliSystemConfigPackages[barrelName] = { main: 'index' };
});

/** Type declaration for ambient System. */
declare var System: any;

// Apply the CLI SystemJS configuration.
System.config({
  map: {
    '@angular': 'vendor/@angular',
    'rxjs': 'vendor/rxjs',
    'main': 'main.js'
  },
  packages: cliSystemConfigPackages
});

// Apply the user's configuration.
System.config({ map, packages });

Sorry finding this all pretty confusing just to include a 3rd party script.

you are correct, beta 5 fixes this issue. thanks!

@dottodot unfortunately, for bundling to work (and thus production builds to work) you can’t import angular2-google-maps.js via a script tag. Instead you have to import it via your app and systemjs.

I agree it’s not very straightforward, and making this process simpler is one of our biggest priorities right now, if not the number 1.

@dottodot re-reading your issue, it seems rather different. The failure of the build to find angular2-google-maps/core.js seems to indicate a misconfiguration in system-config.ts.

Sorry that this has not resolved your issues.

@filipesilva can you take a look at this, I’m assigning it to you.