angular-cli: 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.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 4
- Comments: 43 (4 by maintainers)
If you add the sourcemaps flag, e.g.
ng build --prod -sm
, then the error shows the source file line causing the problem, instead of just the bundle line.A use angular cli but i have no
"uglify-js"
in mypackage.json
to replace. Do you know how to deal with that situation ?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!
Same issue. I may have a bad import but I can’t tell because the UglifyJs error refers to a file that’s never saved, I have no dist folder after this output. This also started for me after upgrading to cli 1.0 and angular 4.0
@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 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” notifications@github.com wrote:
i have same issues, i remove node_modules, then npm install again, and success
I believe this was caused by a module I was importing (‘text-mask-core’) which used default parameters in the source. I was importing directly from the module’s src folder instead of the dist which is compatible. However, this was basically fixed by accident for me and I think it would be good if the error message was improved help investigate these kind of issues.
I had following error,
and it is fixed with
ng build --prod --source-map
later I get heap error andnode --max_old_space_size=12000 ./node_modules/.bin/ng build --prod --source-map
command solved that too.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 🤷♂️.
Hi, I have a similar issue on my project when I try to run “ng build --prod”
I’m targeting es6, so I add the following dev-dependencies, clear the modules and reinstall… but I still have the error.
If someone has an idea to help me, it’s welcome.
@kirillgroshkov You can try replacing the
uglify-js
in yourpackage.json
withIt’s an experimental version of Uglify that works with ES6.
Line 9 of file ./~/cbor/lib/simple.js:
class Simple {
“cbor” is dependency of “autobahn” library what is used in my project. Is it “crob” library issue? Why building by global ang local angular-cli of the same version behave differently?