Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error during prod build in Angular Cli #7725

Closed
cv-gh opened this issue Sep 17, 2017 · 22 comments
Closed

Error during prod build in Angular Cli #7725

cv-gh opened this issue Sep 17, 2017 · 22 comments
Assignees
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent severity3: broken

Comments

@cv-gh
Copy link

cv-gh commented Sep 17, 2017

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.

@umarkashmiri
Copy link

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

image

@ilianiv
Copy link

ilianiv commented Sep 19, 2017

Same here with @angular/[email protected]

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

@thekhoi
Copy link

thekhoi commented Sep 19, 2017

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.

@mistory
Copy link

mistory commented Sep 20, 2017

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

@ilianiv
Copy link

ilianiv commented Sep 20, 2017

@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

@umarkashmiri
Copy link

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
Copy link

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.

@Brocco Brocco added P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent severity3: broken labels Sep 22, 2017
@rodolfojnn
Copy link

rodolfojnn commented Sep 28, 2017

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",
  ],
...

@DmytroPotapov
Copy link

DmytroPotapov commented Oct 9, 2017

@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

@hiepxanh
Copy link
Contributor

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

@Justin-wei
Copy link

Hello,

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

Thanks

@mrahulreddy
Copy link

mrahulreddy commented Oct 25, 2017

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.

@PendelinP
Copy link

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

@bilalsoomro
Copy link

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

@umarkashmiri
Copy link

@sunny061 Use the solution i mentioned

@bilalsoomro
Copy link

@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

@filipesilva
Copy link
Contributor

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 #7610.

@PendelinP
Copy link

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

@umarkashmiri
Copy link

@PendelinP this is what I mentioned above.
#7725 (comment)

@rkkoszewski
Copy link

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?

@darrenjs
Copy link

darrenjs commented Dec 17, 2017

I have similar issue when running ./ng build --prod for ng version 1.5.2

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

I've tracked the problem to the include of a particular script via the .angular-cli.json, I have this :

        "scripts": [
            "../libs/autobahn-js-built-17.5.2/autobahn.js"
        ],

... and further, I suspect the error happens during the minification stage (when uglifyjs would be invoked).

I can't seem to find any way to get further logging / diagnostics from ng , (I tried --verbose but just gives mainly timing stats, rather information on what sub programs are being invoked etc ... perhap ng needs option for more detailed output?) ... will continue digging, suspicion is incompatibility between uglifyjs and the external javascript.

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent severity3: broken
Projects
None yet
Development

No branches or pull requests