Cannot investigate ng build --prod UglifyJs failure
Bug Report or Feature Request (mark with an x)
- [X] bug report -> please search issues before submitting
- [] feature request
Versions.
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
@angular/cli: 1.0.0
node: 6.9.4
os: darwin x64
@angular/animations: 4.0.0
@angular/common: 4.0.0
@angular/compiler: 4.0.0
@angular/compiler-cli: 4.0.0
@angular/core: 4.0.0
@angular/forms: 4.0.0
@angular/http: 4.0.0
@angular/material: 2.0.0-beta.2
@angular/platform-browser: 4.0.0
@angular/platform-browser-dynamic: 4.0.0
@angular/platform-server: 4.0.0
@angular/router: 4.0.0
@angular/cli: 1.0.0
Repro steps.
I run...
ng build --prod
But uglify fails and there's no way to investigate it because the dest folder isn't created on this failure. Specifically trying to investigate Unexpected token operator «=», expected punc «,» .
chunk {0} 0.d17559b9dc1f9710df9e.chunk.js 977 kB {1} {2} [rendered]
chunk {1} 1.3fb611ed62385f1481c5.chunk.js 762 kB {0} {2} [rendered]
chunk {2} main.6670c5c330feeaa5af25.bundle.js (main) 760 kB {5} [initial] [rendered]
chunk {3} scripts.bf4293b30b91e67e776a.bundle.js (scripts) 124 kB {6} [initial] [rendered]
chunk {4} styles.5d73c197136fb409042d.bundle.css (styles) 228 bytes {6} [initial] [rendered]
chunk {5} vendor.1f74f5a264bded28ec07.bundle.js (vendor) 3.63 MB [initial] [rendered]
chunk {6} inline.51a70f6c591274413cac.bundle.js (inline) 0 bytes [entry] [rendered]
ERROR in 0.d17559b9dc1f9710df9e.chunk.js from UglifyJs
Unexpected token operator «=», expected punc «,» [0.d17559b9dc1f9710df9e.chunk.js:9262,39]
The log given by the failure.
Desired functionality.
Would like some more context. The intermediate files should not be deleted on an UglifyJs failure because there's not much to go on.
Mention any other details that might be useful.
This error started for me today after I tried to update to angular 4 and the new angular cli.
Using mishoo/UglifyJS2#harmony resolves the build issue, but doesn't not resolve the issue for users that need to target ES5. There needs to be a way to target ES5 not only for TypeScript, but for JavaScript as well.
Hi, I have a similar issue on my project when I try to run "ng build --prod"
ERROR in main.ec6db48d8ba59a5ab59d.bundle.js from UglifyJs
Unexpected token: name (Utils) [main.ec6db48d8ba59a5ab59d.bundle.js:29,6]
ERROR in vendor.7ad64718ce2c67850294.bundle.js from UglifyJs
Unexpected token: name (AuthGuard) [vendor.7ad64718ce2c67850294.bundle.js:818,6]
I'm targeting es6, so I add the following dev-dependencies, clear the modules and reinstall... but I still have the error.
"uglify-es": "^3.0.0",
"uglify-js": "github:mishoo/UglifyJS2#harmony"
If someone has an idea to help me, it's welcome.
@steveschmitt trick of using --sm to generate the source map provided the clue that my ngx-infinite-scroll had an issue. Prior to the uglify-js error I was having a problem when building ngx-infinite-scroll that it could not find index.js so I moved the node_modules/ngx-infinite-scroll/modules/ngx-infinite-scroll.js to node_modules/ngx-infinite-scroll/index.js For me, the would have been fine because my tsconfig.json target was es2015, but for other reasons I changed my tsconfig.json to target es5 and needed to go back and move node_modules/ngx-infinite-scroll/modules/ngx-infinite-scroll.es5.js to node_modules/ngx-infinite-scroll/modules/index.js. Once I did that change the below uglify error went away.
ERROR in vendor.5c96b46238fbfbd9e2a9.bundle.js from UglifyJs
Unexpected token: name (PositionResolver) [/demo/~/ngx-infinite-scroll/index.js:9,0][vendor.5c96b46238fbfbd9e2a9.bundle.js:20572,6]
I was having this problem as well
ERROR in vendor.c45fa8f7cd4783bc8895.bundle.js from UglifyJs
Unexpected token: name (radix) [vendor.c45fa8f7cd4783bc8895.bundle.js:45505,8]
And solved it by first looking into the sourcemaps (ng build --prod --sm), as suggested by @steveschmitt) which led me to discover that it was a problem with the generatorics npm package
ERROR in vendor.c45fa8f7cd4783bc8895.bundle.js from UglifyJs
Unexpected token: name (radix) [/Users/maiasmith/git_repos/presentation-template-ng2/~/generatorics/generatorics.js:43,0][vendor.c45fa8f7cd4783bc8895.bundle.js:45505,8]
I removed the package, and problem solved!
i have no "uglify-js" in my package.json to replace what should i do ??
@fabien-chevalley did you find any solution ? i applied the sugestions above but seems like uglify-js is still used
@steveschmitt i can't find "uglify-js" in package.json because it's a nested dependency of angular-cli though just adding it doesn't change anything for the most of us. Any idea ? maybe you use a specific version of angular-cli that doesn't nest uglify-js ? Thanks
I think I installed the experimental uglify-js at the top level, and removed the nested one, and it just worked. Recent npm versions won't install a nested package if you already have a compatible version installed at the top level.
Steve
On Oct 20, 2017 8:59 PM, "Youssef GHOUBACH" [email protected] wrote:
@steveschmitt https://github.com/steveschmitt i can't find "uglify-js" in package.json because it's a nested dependency of angular-cli though just adding it doesn't change anything for the most of us. Any idea ? maybe you use a specific version of angular-cli that doesn't nest uglify-js ? Thanks
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/angular/angular-cli/issues/5741#issuecomment-338239909, or mute the thread https://github.com/notifications/unsubscribe-auth/ABmCtms80kvLH9QL8hiA6XPgD8uDrKVsks5suLxNgaJpZM4MtkQ9 .
@youssefgh I try to move on Angular-Cli 1.5 to have the following modification #7610, the production build is now working, but I'm not able to serve my application #7797 anymore...
So I didn't have any solution for the moment
I moved to cli 1.5.0-rc.2 as a workaround until 1.5 is released For anyone having the same problem here is my changes:
- move to : "@angular/cli": "1.5.0-rc.2"
- make sure that target is set to "es2015" in tsconfig.json
- serve using : ng serve --aot
Thanks a lot guys for you help ;)
I got the same issue using 1.5. I tried both ng build --prod --aot and ng build --prod --aot false. The error says:
Unexpected token: name (MyService) [main.9ccecc27d4a5724997c5.bundle.js:20,6
@ShinDarth i no longer have this issue using 1.5 and even without using --aot. I think you have a different problem can you make sure that target is set to "es2015" in tsconfig.json ? if you still have the same issue try building with : ng build --prod --sm to see what lib is causing your error
@youssefgh I did it, in my case it's not a lib but my source code
@ShinDarth then (i think) just changing the es6+ syntax in your code to a ES2015 compliant should resolve your problem see above comment :
If you use the -sm flag to know what file is causing problems, and you have access to the file, the solution (atleast for me) was to not use es6+ features in that file. Removing all es6+ features made this error go away.
yes I used --sm flag to check which line of my code is actually causing it, but it's this line:
export class MyService {
That is weird that a simple class in an angular project can cause this Can you share a sample project that reproduce this error ?
@youssefgh I'm not able to reproduce the problem in other projects. Actually I'm even having troubles in reproducing it with the same project across different machines...
I solved mine by removing repeated codes inside my assets folder.
For those interested in Angular CLI v6.* the flag is now --source-map.
For me, source maps helped me identify a trailing comma in my function parameters that was breaking uglifyJS 🤷♂️.
Hello ,
Here is the error i face after running ng build --prod. Please can someone help me out!!
ERROR in 10.ef56b443a514b22853bd.chunk.js from UglifyJs
TypeError: Cannot set property 'fixed' of undefined
at TreeWalker.eval [as visit] (eval at