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

Error during prod build in Angular Cli

Open cv-gh opened this issue 9 years ago • 22 comments

Bug Report or Feature Request (mark with an x)

- [X ] bug report -> please search issues before submitting
- [ ] feature request

Versions.

Repro steps.

The log given by the failure.

94% asset optimization(node:11160) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): SyntaxError: Unexpected token: operator (>) (node:11160) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Desired functionality.

Mention any other details that might be useful.

I can do normal build only build in prod fails with above error. greatly appreciate help here. While I have read the Promise Then and Catch - I have followed the pattern in my source code every where but exact issue is missing and I cant really build anymore.

cv-gh avatar Sep 17 '17 16:09 cv-gh

I am getting the same here. Here is the version detail image and TSCONFIG

image

umarkashmiri avatar Sep 19 '17 03:09 umarkashmiri

Same here with @angular/[email protected]

94% asset optimization(node:20368) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): SyntaxError: Unexpected token: name (f)

ilianiv avatar Sep 19 '17 07:09 ilianiv

I got this error when I included a script file inside the angular-cli.json written in es6. I converted it to es5 by change 'let' back to 'var' and removing arrow functions.

thekhoi avatar Sep 19 '17 20:09 thekhoi

Im getting this error when i run ng build --prod

 95% emittingUnhandled rejection Error: ENOENT: no such file or directory, open
'C:\Users\story\pro\ng-app\node_modules\_@[email protected]@@angular\packa
ge.json'

The version is:

@angular/cli: 1.4.2
node: 7.10.0
os: win32 x64
@angular/animations: 4.4.3
@angular/common: 4.4.3
@angular/compiler: 4.4.3
@angular/core: 4.4.3
@angular/forms: 4.4.3
@angular/http: 4.4.3
@angular/platform-browser: 4.4.3
@angular/platform-browser-dynamic: 4.4.3
@angular/router: 4.4.3
@angular/cli: 1.4.2
@angular/compiler-cli: 4.4.3
@angular/language-service: 4.4.3
typescript: 2.3.4

mistory avatar Sep 20 '17 06:09 mistory

@thekhoi you are right. I've got a custom script included in .angular-cli.json written in es6. Transpiling to es5 fixed the issue with SyntaxError: Unexpected token: name (f) when building with -prod flag

ilianiv avatar Sep 20 '17 06:09 ilianiv

Yes, one thing is confirmed, this is due to external scripts. I am using bootstrap 4 in my project and it has a dependency on popper.min.js and it is based on es6. I changed my "target": "es2016", in my tsconfig file and it's working now besides a few warnings, still figuring out how to get rid of them.

umarkashmiri avatar Sep 20 '17 18:09 umarkashmiri

updating to es2016 was still messing up with some of my other libraries and it was not suitable. so what I did, I installed popper.js separately via npm and used umd version which is compatible with es5, and changed the target to es5 again in tsconfig and it solved my problem.

umarkashmiri avatar Sep 20 '17 18:09 umarkashmiri

Same here. I also use Bootstrap 4 and Pooper.js.

@angular/cli: 1.4.3 node: 7.5.0 os: win32 x64 @angular/animations: 4.3.2 @angular/common: 4.3.2 @angular/compiler: 4.3.2 @angular/compiler-cli: 4.3.2 @angular/core: 4.3.2 @angular/forms: 4.3.2 @angular/http: 4.3.2 @angular/platform-browser: 4.3.2 @angular/platform-browser-dynamic: 4.3.2 @angular/platform-server: 4.3.2 @angular/router: 4.3.2 @angular/cli: 1.4.3 typescript: 2.3.4

.angular-cli.json

...
"scripts": [
    "../node_modules/popper.js/dist/umd/popper.min.js",
    "../node_modules/bootstrap/dist/js/bootstrap.min.js",
  ],
...

rodolfojnn avatar Sep 28 '17 11:09 rodolfojnn

@thekhoi

I got this error when I included a script file inside the angular-cli.json written in es6. I converted it to es5 by change 'let' back to 'var' and removing arrow functions.

Thanks, it restore production build for me

DmytroPotapov avatar Oct 09 '17 11:10 DmytroPotapov

@chetanvaja did you resolve this issue sir ? can you close this if you finished ?

hiepxanh avatar Oct 19 '17 09:10 hiepxanh

Hello,

It is still not work with version 1.4.9, any workaround?

Thanks

Justin-wei avatar Oct 23 '17 07:10 Justin-wei

Same here with @angular/[email protected]

94% asset optimization(node:235548) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): SyntaxError: Unexpected token: name (Doubl eQtyHinge)

How do we fix this? Anyone please respond I am in haste.

mrahulreddy avatar Oct 25 '17 15:10 mrahulreddy

Same here -> working with Bootstrap 4 and Popper.js

PendelinP avatar Oct 31 '17 09:10 PendelinP

Facing the same issue in @angular/[email protected] when trying to user Bootstrap with Popper.js in my Angular app.

bilalsoomro avatar Nov 01 '17 09:11 bilalsoomro

@sunny061 Use the solution i mentioned

umarkashmiri avatar Nov 01 '17 11:11 umarkashmiri

@umarkashmiri I've temporarily solved the problem by downgrading the angular cli to 1.3.2 as mentioned in this answer. https://stackoverflow.com/a/46330054/1874266

bilalsoomro avatar Nov 01 '17 16:11 bilalsoomro

This type of error occurs when you try to use ES2015 vendor code with a ES5 app. It was addressed when we added ES2105 support in https://github.com/angular/angular-cli/pull/7610.

filipesilva avatar Nov 04 '17 18:11 filipesilva

I found a solution: https://stackoverflow.com/a/47654981/1820522

PendelinP avatar Dec 05 '17 15:12 PendelinP

@PendelinP this is what I mentioned above. https://github.com/angular/angular-cli/issues/7725#issuecomment-330939271

umarkashmiri avatar Dec 05 '17 15:12 umarkashmiri

I have the same issue. I'm not using Bootstrap nor popper.js. As this issue post has been closed, I suppose this has been fixed. But where and how? My "target" is "es5" while my "lib" is "es2017". Could this be the issue? Changing es5 to es2017 yields the same result. Any help or fix?

rkkoszewski avatar Dec 13 '17 08:12 rkkoszewski