angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

ng serve -prod fails (beta 5)

Open ddiazpinto opened this issue 10 years ago • 53 comments

  1. OS? Debian Jessie

  2. Versions. Please run ng --version. angular-cli: 1.0.0-beta.5 node: 5.11.1 os: linux x64

  3. 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 ngtestmobile --mobile
    2. cd ngtestmobile
    3. ng serve -- works normally.
    4. ng serve -prod -- doesn't work.

    No changes in the code.

  4. The log given by the failure. Normally this include a stack trace and some more information.

$ ng serve -prod
Could not start watchman; falling back to NodeWatcher for file system events.
Visit http://ember-cli.com/user-guide/#watchman for more info.
Livereload server on http://localhost:49152
Serving on http://localhost:4200/
The Broccoli Plugin: [SourceMapConcat] failed with:
Error: ENOENT: no such file or directory, open '/home/daviddiaz/projects/tests/ngtestmobile/tmp/source_map_concat-input_base_path-dxPccJ6Q.tmp/0/vendor/reflect-metadata/Reflect.ts'
    at Error (native)
    at Object.fs.openSync (fs.js:584:18)
    at Object.fs.readFileSync (fs.js:431:33)
    at SourceMap.<anonymous> (/home/daviddiaz/projects/tests/ngtestmobile/node_modules/angular-cli/node_modules/broccoli-concat/node_modules/fast-sourcemap-concat/lib/source-map.js:282:29)
    at Array.map (native)
    at Object.Call (/home/daviddiaz/projects/tests/ngtestmobile/node_modules/es6-shim/es6-shim.js:289:14)
    at Array.map (/home/daviddiaz/projects/tests/ngtestmobile/node_modules/es6-shim/es6-shim.js:1301:17)
    at SourceMap._resolveSourcesContent (/home/daviddiaz/projects/tests/ngtestmobile/node_modules/angular-cli/node_modules/broccoli-concat/node_modules/fast-sourcemap-concat/lib/source-map.js:275:27)
    at SourceMap._assimilateExistingMap (/home/daviddiaz/projects/tests/ngtestmobile/node_modules/angular-cli/node_modules/broccoli-concat/node_modules/fast-sourcemap-concat/lib/source-map.js:248:63)
    at SourceMap.<anonymous> (/home/daviddiaz/projects/tests/ngtestmobile/node_modules/angular-cli/node_modules/broccoli-concat/node_modules/fast-sourcemap-concat/lib/source-map.js:219:12)
    at SourceMap._cacheEncoderResults (/home/daviddiaz/projects/tests/ngtestmobile/node_modules/angular-cli/node_modules/broccoli-concat/node_modules/fast-sourcemap-concat/lib/source-map.js:125:16)
    at SourceMap._addMap (/home/daviddiaz/projects/tests/ngtestmobile/node_modules/angular-cli/node_modules/broccoli-concat/node_modules/fast-sourcemap-concat/lib/source-map.js:218:10)
    at SourceMap.addFileSource (/home/daviddiaz/projects/tests/ngtestmobile/node_modules/angular-cli/node_modules/broccoli-concat/node_modules/fast-sourcemap-concat/lib/source-map.js:92:19)
    at SourceMap.addFile (/home/daviddiaz/projects/tests/ngtestmobile/node_modules/angular-cli/node_modules/broccoli-concat/node_modules/fast-sourcemap-concat/lib/source-map.js:70:15)
    at /home/daviddiaz/projects/tests/ngtestmobile/node_modules/angular-cli/node_modules/broccoli-concat/concat.js:100:16
    at Array.forEach (native)

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

This problem only happen using the --mobile flag when tries to concat the vendor polyfills to build app-concat.js in index.html.


ddiazpinto avatar May 19 '16 20:05 ddiazpinto

OS X Mac El Capitan ng version beta.5 For me ng build -prod not work Error trace:

Alexs-iMac:angular-bbc alex$ ng build -o public -w -prod
(node:8234) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
⠸ Building(node:8234) DeprecationWarning: 'root' is deprecated, use 'global'
(node:8234) DeprecationWarning: 'GLOBAL' is deprecated, use 'global'
⠼ BuildingThe Broccoli Plugin: [BundlePlugin] failed with:
Error on fetch for main.js at file:///Users/alex/Sites/sitesforchurch/angular-bbc/tmp/bundle_plugin-input_base_path-qp8Zs918.tmp/0/main.js
        Error: ENOENT: no such file or directory, open '/Users/alex/Sites/sitesforchurch/angular-bbc/tmp/bundle_plugin-input_base_path-qp8Zs918.tmp/0/Users/alex/Sites/sitesforchurch/angular-bbc/tmp/broccoli_type_script_compiler-input_base_path-flSQOaxZ.tmp/0/main.js.map'
    at Error (native)

The broccoli plugin was instantiated at: 
    at BundlePlugin.Plugin (/Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/broccoli-plugin/index.js:10:31)
    at BundlePlugin.CachingWriter [as constructor] (/Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/broccoli-caching-writer/index.js:21:10)
    at BundlePlugin (/Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/angular-cli/lib/broccoli/angular-broccoli-bundle.js:11:5)
    at Angular2App._getBundleTree (/Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/angular-cli/lib/broccoli/angular2-app.js:421:22)
    at Angular2App._buildTree (/Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/angular-cli/lib/broccoli/angular2-app.js:159:21)
    at new Angular2App (/Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/angular-cli/lib/broccoli/angular2-app.js:53:23)
    at module.exports (/Users/alex/Sites/sitesforchurch/angular-bbc/angular-cli-build.js:6:10)
    at Class.module.exports.Task.extend.setupBroccoliBuilder (/Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/angular-cli/lib/models/builder.js:55:19)
    at Class.module.exports.Task.extend.init (/Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/angular-cli/lib/models/builder.js:89:10)
    at new Class (/Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/core-object/core-object.js:18:12)
    at Class.module.exports.Task.extend.run (/Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/angular-cli/lib/tasks/build-watch.js:17:16)
    at /Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/angular-cli/lib/commands/build.js:32:24
    at lib$rsvp$$internal$$tryCatch (/Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/rsvp/dist/rsvp.js:1036:16)
    at lib$rsvp$$internal$$invokeCallback (/Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/rsvp/dist/rsvp.js:1048:17)
    at /Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/rsvp/dist/rsvp.js:331:11
    at lib$rsvp$asap$$flush (/Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/rsvp/dist/rsvp.js:1198:9)


The Broccoli Plugin: [BundlePlugin] failed with:
Error on fetch for main.js at file:///Users/alex/Sites/sitesforchurch/angular-bbc/tmp/bundle_plugin-input_base_path-qp8Zs918.tmp/0/main.js
        Error: ENOENT: no such file or directory, open '/Users/alex/Sites/sitesforchurch/angular-bbc/tmp/bundle_plugin-input_base_path-qp8Zs918.tmp/0/Users/alex/Sites/sitesforchurch/angular-bbc/tmp/broccoli_type_script_compiler-input_base_path-flSQOaxZ.tmp/0/main.js.map'
    at Error (native)

The broccoli plugin was instantiated at: 
    at BundlePlugin.Plugin (/Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/broccoli-plugin/index.js:10:31)
    at BundlePlugin.CachingWriter [as constructor] (/Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/broccoli-caching-writer/index.js:21:10)
    at BundlePlugin (/Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/angular-cli/lib/broccoli/angular-broccoli-bundle.js:11:5)
    at Angular2App._getBundleTree (/Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/angular-cli/lib/broccoli/angular2-app.js:421:22)
    at Angular2App._buildTree (/Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/angular-cli/lib/broccoli/angular2-app.js:159:21)
    at new Angular2App (/Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/angular-cli/lib/broccoli/angular2-app.js:53:23)
    at module.exports (/Users/alex/Sites/sitesforchurch/angular-bbc/angular-cli-build.js:6:10)
    at Class.module.exports.Task.extend.setupBroccoliBuilder (/Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/angular-cli/lib/models/builder.js:55:19)
    at Class.module.exports.Task.extend.init (/Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/angular-cli/lib/models/builder.js:89:10)
    at new Class (/Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/core-object/core-object.js:18:12)
    at Class.module.exports.Task.extend.run (/Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/angular-cli/lib/tasks/build-watch.js:17:16)
    at /Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/angular-cli/lib/commands/build.js:32:24
    at lib$rsvp$$internal$$tryCatch (/Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/rsvp/dist/rsvp.js:1036:16)
    at lib$rsvp$$internal$$invokeCallback (/Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/rsvp/dist/rsvp.js:1048:17)
    at /Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/rsvp/dist/rsvp.js:331:11
    at lib$rsvp$asap$$flush (/Users/alex/Sites/sitesforchurch/angular-bbc/node_modules/rsvp/dist/rsvp.js:1198:9)

Codenator81 avatar May 19 '16 22:05 Codenator81

This issue is also affecting Windows. The "BundlePlugin" is throwing an exception when building for PROD.

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

jairo@DESKTOP-PDVD5FQ MINGW64 /c/repo/test-delete/test_ (master)
$ ng build -prod
Build failed.
The Broccoli Plugin: [BundlePlugin] failed with:
Error on fetch for main.js at file:///C:/repo/test-delete/test_/tmp/bundle_plugin-input_base_path-tOFsVjuQ.tmp/0/main.js
        Error: ENOENT: no such file or directory, open 'C:\repo\test-delete\test_\tmp\bundle_plugin-input_base_path-tOFsVjuQ.tmp\0\C:\repo\test-delete\test_\tmp\broccoli_type_script_compiler-input_base_path-KuOLmzKn.tmp\0\main.js.map'
    at Error (native)

The broccoli plugin was instantiated at:
    at BundlePlugin.Plugin (C:\repo\test-delete\test_\node_modules\angular-cli\node_modules\broccoli-caching-writer\node_modules\broccoli-plugin\index.js:10:31)
    at BundlePlugin.CachingWriter [as constructor] (C:\repo\test-delete\test_\node_modules\angular-cli\node_modules\broccoli-caching-writer\index.js:21:10)
    at BundlePlugin (C:\repo\test-delete\test_\node_modules\angular-cli\lib\broccoli\angular-broccoli-bundle.js:10:36)
    at Angular2App._getBundleTree (C:\repo\test-delete\test_\node_modules\angular-cli\lib\broccoli\angular2-app.js:421:22)
    at Angular2App._buildTree (C:\repo\test-delete\test_\node_modules\angular-cli\lib\broccoli\angular2-app.js:159:21)
    at new Angular2App (C:\repo\test-delete\test_\node_modules\angular-cli\lib\broccoli\angular2-app.js:53:23)
    at module.exports (C:\repo\test-delete\test_\angular-cli-build.js:6:10)
    at Class.module.exports.Task.extend.setupBroccoliBuilder (C:\repo\test-delete\test_\node_modules\angular-cli\node_modules\angular-cli\lib\models\builder.js:55:19)
    at Class.module.exports.Task.extend.init (C:\repo\test-delete\test_\node_modules\angular-cli\node_modules\angular-cli\lib\models\builder.js:89:10)
    at new Class (C:\repo\test-delete\test_\node_modules\angular-cli\node_modules\angular-cli\node_modules\core-object\core-object.js:18:12)
    at Class.module.exports.Task.extend.run (C:\repo\test-delete\test_\node_modules\angular-cli\node_modules\angular-cli\lib\tasks\build.js:15:19)
    at C:\repo\test-delete\test_\node_modules\angular-cli\node_modules\angular-cli\lib\commands\build.js:32:24
    at lib$rsvp$$internal$$tryCatch (C:\repo\test-delete\test_\node_modules\angular-cli\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1036:16)
    at lib$rsvp$$internal$$invokeCallback (C:\repo\test-delete\test_\node_modules\angular-cli\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1048:17)
    at lib$rsvp$$internal$$publish (C:\repo\test-delete\test_\node_modules\angular-cli\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1019:11)
    at lib$rsvp$asap$$flush (C:\repo\test-delete\test_\node_modules\angular-cli\node_modules\angular-cli\node_modules\rsvp\dist\rsvp.js:1198:9)

zorthgo avatar May 21 '16 09:05 zorthgo

It seems that your error is different than mine. Did you make any change in the code before serve or build as prod? Did you create the app via ng new with the --mobile flag or without it?

ddiazpinto avatar May 21 '16 16:05 ddiazpinto

@ddiazpinto I create app via ng new and don`t do any changes to code

Codenator81 avatar May 21 '16 20:05 Codenator81

@ddiazpinto Same here. That is a brand new angular-cli solution. I used the "new" keyword to generate the solution, and ran "ng build -prod" without touching any of the files.

zorthgo avatar May 22 '16 14:05 zorthgo

+1

BhaskaranR avatar May 22 '16 16:05 BhaskaranR

+1

allrore avatar May 23 '16 00:05 allrore

+1

vitormalencar avatar May 23 '16 01:05 vitormalencar

+1

unnijeevan avatar May 23 '16 05:05 unnijeevan

+1

Tusabras avatar May 23 '16 08:05 Tusabras

Heya all, just wanted to let you know that we're aware of this issue and that I'm picking it up later today to try and fix it.

filipesilva avatar May 23 '16 08:05 filipesilva

This broke angular-cli retroactively (all the way back to 0.0.37), so it appears to be a problem with a dep. i.e. fixing that dep's version number in the package.json "should" resolve it. (That said, i have no idea which dep, nor which version.)

sgbeal avatar May 23 '16 09:05 sgbeal

A workaround for desperate users: revert to ng 0.0.34. You won't get bundles (so 300+ requests at app startup), but it otherwise seems to work.

sgbeal avatar May 23 '16 09:05 sgbeal

I know which dependency broke it. It was SystemJS, and https://github.com/angular/angular-cli/pull/839 should have fixed it for new projects... but apparently it didn't?

The issue described by @ddiazpinto seems to be different, and related to differences between mobile and non-mobile build steps.

filipesilva avatar May 23 '16 09:05 filipesilva

Guys, I just tried this with a branch new 1.0.0-beta.5 project and everything seems work. Can I ask you to run these commands?

npm cache clean
npm install -g [email protected]
ng new testproj
cd testproj
ng build
ng build -prod

@ddiazpinto your issue is different though, I need to research it more thoroughly.

filipesilva avatar May 23 '16 09:05 filipesilva

@filipesilva those exact steps work for me now (they didn't when i filed #888 a couple hours ago!), but it's not working in our project tree: we are stuck with beta.1 because of #833. Testing with that version and systemjs 0.19.26 (same as current ng new) we are still getting the missing map error:

        $ ng build -prod
        (node:8784) fs: re-evaluating native module sources is not supported. If you are using the graceful-fs module, please update it to a more recent version.
        (node:8784) DeprecationWarning: 'root' is deprecated, use 'global'
        (node:8784) DeprecationWarning: 'GLOBAL' is deprecated, use 'global'
        Build failed.
        The Broccoli Plugin: [BundlePlugin] failed with:
        Error on fetch for main.js at file:///D:/src/maros/nms-facade/nms-gui-parent/nms-gui/tmp/bundle_plugin-input_base_path-HeAs0V2W.tmp/0/main.js
                Error: ENOENT: no such file or directory, open 'D:\src\maros\nms-facade\nms-gui-parent\nms-gui\tmp\bundle_plugin-input_base_path-HeAs0V2W.tmp\0\main.js.map'
            at Error (native)

So.... i mangled our tree to work around #833, just to try it out, but the error remains.

Any hint on which toggle i need here would be much appreciated! i have tried simply disabling maps via tsconfig, but it still wants the maps at bundle-time.

sgbeal avatar May 23 '16 10:05 sgbeal

@sgbeal for existing projects, the fix should be this:

  • make sourcemaps relative in tsconfig.json by removing mapRoot: https://github.com/angular/angular-cli/pull/839/files#diff-07a68a6787db2e2ff85093b708c543f4
  • configure angular-cli-build.js to also copy vendor map files: https://github.com/angular/angular-cli/pull/839/files#diff-7d92ebc9f7d559179bf60ebf7f3a4f43
  • update local project angular-cli version to 1.0.0-beta.5.

filipesilva avatar May 23 '16 10:05 filipesilva

@filipesilva you are my hero :). That works... but we can't use beta.5 because of #833 (imports in environment.xxx.ts cannot be resolved, and we rely on that to import dev-time mocks and set up logging service log levels in prod) :(.

Just tried that same thing with beta 1, but it's still looking for maps :(.

sgbeal avatar May 23 '16 10:05 sgbeal

Just re-verified: the above fix works for us with beta.5 only if we remove all imports and references to globals (e.g. window and console) from environment.prod.ts. As soon as we reference, or try to import, any external symbols, they cannot be imported/resolved.

sgbeal avatar May 23 '16 10:05 sgbeal

As far as globals are concerned, they are a typings issue - compounded with bad module resolution for env files on the cli part.

You should be able to get around it with something like declare var window: any; directly on the problematic env file.

filipesilva avatar May 23 '16 10:05 filipesilva