Uglifyjs: Uncaught Error: Cannot find module '../lib/utils.js'.

Created on 20 Jun 2017  路  7Comments  路  Source: mishoo/UglifyJS

Hi, I was trying to use uglifyjs programmatically but got this error. Anyone know how can i solve it?

Most helpful comment

What is the reason?How to deal with it

All 7 comments

Please provide a reproducible test case to illustrate your issue - there is nothing actionable with the current level of information.

I'm building a react app and using webpack to bundle it.

This line
var UglifyJS = require("uglify-js");
causes the following:

Uncaught Error: Cannot find module '../lib/utils.js'.
at eval (eval at (http://localhost:3000/static/bundle.js:1:3284122), :13:41)
at Function.webpackContextResolve [as resolve] (eval at (http://localhost:3000/static/bundle.js:1:3284122), :13:89)
at eval (eval at (http://localhost:3000/static/bundle.js:1:3277347), :18:57)
at Array.map (native)
at eval (eval at (http://localhost:3000/static/bundle.js:1:3277347), :17:3)
at Object. (http://localhost:3000/static/bundle.js:1:3277347)
at s (http://localhost:3000/static/bundle.js:1:5619)
at c (http://localhost:3000/static/bundle.js:1:1165)
at eval (eval at (http://localhost:3000/static/bundle.js:1:3267753), :12:16)
at Object. (http://localhost:3000/static/bundle.js:1:3267753)

Sounds like a webpack issue - please file a report with them instead.

My understanding is that they are pulling out and rearranging files from uglify-js, and something breaks along the way.

Got it. Thanks!

Got it. Thanks!

How to do it

What is the reason?How to deal with it

I think it's the problem of uglifyJs, the require grammar can't be static analyzed by webpack.

Was this page helpful?
0 / 5 - 0 ratings