Angular-cli: Serving or building on --prod giving error

Created on 22 Feb 2017  路  6Comments  路  Source: angular/angular-cli

Please provide us with the following information:

OS?

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

Versions.

Please run ng --version. If there's nothing outputted, please run in a Terminal: node --version and paste the result here:
@angular/cli: 1.0.0-beta.32.3
node: 6.9.5
os: win32 x64
@angular/common: 2.4.8
@angular/compiler: 2.4.8
@angular/core: 2.4.8
@angular/forms: 2.4.8
@angular/http: 2.4.8
@angular/platform-browser: 2.4.8
@angular/platform-browser-dynamic: 2.4.8
@angular/router: 3.4.8
@angular/cli: 1.0.0-beta.32.3
@angular/compiler-cli: 2.4.8

Repro steps.

Was this an app that wasn't created using the CLI? What change did you do on your code? etc.
When im either serving or building in production mode it gives me a error about object not being defined. But when i run on --dev it works fine.

The log given by the failure.

Normally this include a stack trace and some more information.
EXCEPTION: Uncaught (in promise): ReferenceError: object is not defined ReferenceError: object is not defined at Object.789 (http://localhost:4200/0.452b78dd1b17e360febd.chunk.js:1:2658) at r (http://localhost:4200/inline.b78ac715cc2b7d1e48dd.bundle.js:1:101) at http://localhost:4200/main.da4b0c88edefed1d24f0.bundle.js:1:850 at t.invoke (http://localhost:4200/polyfills.107db3521ec94eb97f9f.bundle.js:36:8986) at Object.onInvoke (http://localhost:4200/vendor.fa8f6e8ba41e1ad6169b.bundle.js:246:2659) at t.invoke (http://localhost:4200/polyfills.107db3521ec94eb97f9f.bundle.js:36:8926) at n.run (http://localhost:4200/polyfills.107db3521ec94eb97f9f.bundle.js:36:4721) at http://localhost:4200/polyfills.107db3521ec94eb97f9f.bundle.js:36:1785 at t.invokeTask (http://localhost:4200/polyfills.107db3521ec94eb97f9f.bundle.js:36:9670) at Object.onInvokeTask (http://localhost:4200/vendor.fa8f6e8ba41e1ad6169b.bundle.js:246:2559) at t.invokeTask (http://localhost:4200/polyfills.107db3521ec94eb97f9f.bundle.js:36:9591) at n.runTask (http://localhost:4200/polyfills.107db3521ec94eb97f9f.bundle.js:36:5370) at i (http://localhost:4200/polyfills.107db3521ec94eb97f9f.bundle.js:36:497)

Mention any other details that might be useful.


Thanks! We'll be in touch soon.

repro steps

Most helpful comment

same problem here. here is what I get.
prod mode:

ng build -prod -w -d /projectName
 10% building modules 5/5 modules 0 active(node:4190) DeprecationWarning: loaderUtils.parseQuery() received a non-string value which can be problematic, see https://github.com/webpack/loader-utils/issues/56
parseQuery() will be replaced with getOptions() in the next major version of loader-utils.
Hash: ed7bfd4e700de89aa779
Time: 13560ms
chunk    {0} styles.8afad99341b65bf5cb81.bundle.css (styles) 228 bytes {3} [initial] [rendered]
chunk    {1} main.8477c1fedbf068d1d303.bundle.js (main) 1.34 kB {2} [initial] [rendered]
chunk    {2} vendor.3af1d75f8c391113e41f.bundle.js (vendor) 1.05 MB [initial] [rendered]
chunk    {3} inline.db5dd24fa3dbb04c933a.bundle.js (inline) 0 bytes [entry] [rendered]

ERROR in Unexpected value 'nvD3' declared by the module 'AppModule'

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/home/user/projectName/src'
 @ ./src/main.ts 5:0-74
 @ multi ./src/main.ts

dev mode:

ng build -d /projectName
 10% building modules 6/6 modules 0 active(node:4524) DeprecationWarning: loaderUtils.parseQuery() received a non-string value which can be problematic, see https://github.com/webpack/loader-utils/issues/56
parseQuery() will be replaced with getOptions() in the next major version of loader-utils.
Hash: fe70a9771b3656fe5ee9
Time: 20750ms
chunk    {0} main.bundle.js, main.bundle.js.map (main) 37.9 kB {2} [initial] [rendered]
chunk    {1} styles.bundle.js, styles.bundle.js.map (styles) 51.4 kB {3} [initial] [rendered]
chunk    {2} vendor.bundle.js, vendor.bundle.js.map (vendor) 5.59 MB [initial] [rendered]
chunk    {3} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]

All 6 comments

same problem here. here is what I get.
prod mode:

ng build -prod -w -d /projectName
 10% building modules 5/5 modules 0 active(node:4190) DeprecationWarning: loaderUtils.parseQuery() received a non-string value which can be problematic, see https://github.com/webpack/loader-utils/issues/56
parseQuery() will be replaced with getOptions() in the next major version of loader-utils.
Hash: ed7bfd4e700de89aa779
Time: 13560ms
chunk    {0} styles.8afad99341b65bf5cb81.bundle.css (styles) 228 bytes {3} [initial] [rendered]
chunk    {1} main.8477c1fedbf068d1d303.bundle.js (main) 1.34 kB {2} [initial] [rendered]
chunk    {2} vendor.3af1d75f8c391113e41f.bundle.js (vendor) 1.05 MB [initial] [rendered]
chunk    {3} inline.db5dd24fa3dbb04c933a.bundle.js (inline) 0 bytes [entry] [rendered]

ERROR in Unexpected value 'nvD3' declared by the module 'AppModule'

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/home/user/projectName/src'
 @ ./src/main.ts 5:0-74
 @ multi ./src/main.ts

dev mode:

ng build -d /projectName
 10% building modules 6/6 modules 0 active(node:4524) DeprecationWarning: loaderUtils.parseQuery() received a non-string value which can be problematic, see https://github.com/webpack/loader-utils/issues/56
parseQuery() will be replaced with getOptions() in the next major version of loader-utils.
Hash: fe70a9771b3656fe5ee9
Time: 20750ms
chunk    {0} main.bundle.js, main.bundle.js.map (main) 37.9 kB {2} [initial] [rendered]
chunk    {1} styles.bundle.js, styles.bundle.js.map (styles) 51.4 kB {3} [initial] [rendered]
chunk    {2} vendor.bundle.js, vendor.bundle.js.map (vendor) 5.59 MB [initial] [rendered]
chunk    {3} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]

If you give a simple repro I can look into it.

Versions:

```ng --version

                         _                           _  _

__ _ _ __ __ _ _ _ | | __ _ _ __ ___ | |(_)
/ _|| '_ \ / _ || | | || | / _` || '__|_____ / __|| || |
| (_| || | | || (_| || |_| || || (_| || | |_____|| (__ | || |
__,_||_| |_| __, | __,_||_| __,_||_| ___||_||_|
|___/
@angular/cli: 1.0.0-beta.32.3 [1.0.0-beta.26]
node: 6.9.1
os: linux x64
@angular/common: 2.4.9
@angular/compiler: 2.4.9
@angular/core: 2.4.9
@angular/flex-layout: 2.0.0-rc.1
@angular/forms: 2.4.9
@angular/http: 2.4.9
@angular/material: 2.0.0-beta.1
@angular/platform-browser: 2.4.9
@angular/platform-browser-dynamic: 2.4.9
@angular/router: 3.4.9
@angular/compiler-cli: 2.4.9
@angular/cli: 1.0.0-beta.32.3

install dependencies: 

npm install --save d3
npm install --save nvD3
npm install --save ng2-nvd3

in app.module.ts :

```//ndv3 imports
import "d3";
import "nvd3";
import { nvD3 } from 'ng2-nvd3';

include nvD3 in declarations.

run:

ng build -prod

or

ng serve -prod 

should result in the following error.

Hash: cf1b6d6b325beb8b0762
Time: 19465ms
chunk    {0} styles.966410b3b28262b59537.bundle.css (styles) 228 bytes {3} [initial] [rendered]
chunk    {1} main.a00ec9695b73ac41aee8.bundle.js (main) 1.34 kB {2} [initial] [rendered]
chunk    {2} vendor.623c43eff969d9fc9b35.bundle.js (vendor) 1.04 MB [initial] [rendered]
chunk    {3} inline.318cb148416249acbb60.bundle.js (inline) 0 bytes [entry] [rendered]

ERROR in Unexpected value 'nvD3 in /home/project_path/node_modules/ng2-nvd3/build/lib/ng2-nvd3.d.ts' declared by the module 'AppModule in /home/project_path/src/app/app.module.ts'

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/home/project_path/src'
 @ ./src/main.ts 5:0-74
 @ multi ./src/main.ts

@filipesilva please confirm if you are able to reproduce the issue.

Seems like a problem with that nvD3 library. It doesn't seem to be compatible with AOT.

ERROR in Unexpected value 'nvD3 in /home/project_path/node_modules/ng2-nvd3/build/lib/ng2-nvd3.d.ts' declared by the module 'AppModule in /home/project_path/src/app/app.module.ts'

Please open an issue in their repository.

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

_This action has been performed automatically by a bot._

Was this page helpful?
0 / 5 - 0 ratings