node-uglifier icon indicating copy to clipboard operation
node-uglifier copied to clipboard

Cannot read property 'toString' of undefined

Open el-j opened this issue 7 years ago • 3 comments

When i try to uglify after the merge, i get this error:

/<directory>/node_modules/node-uglifier-es/lib_compiled/NodeUglifier.js:353
      return this.lastResult.source.toString();
                                    ^

TypeError: Cannot read property 'toString' of undefined
    at NodeUglifier.toString (/<directory>/node_modules/node-uglifier-es/lib_compiled/NodeUglifier.js:353:37)
    at NodeUglifier.exportToFile (/<directory>/node_modules/node-uglifier-es/lib_compiled/NodeUglifier.js:362:41)
    at Object.<anonymous> (/<directory>/buildServer.js:14:14)
    at Module._compile (module.js:643:30)
    at Object.Module._extensions..js (module.js:654:10)
    at Module.load (module.js:556:32)
    at tryModuleLoad (module.js:499:12)
    at Function.Module._load (module.js:491:3)
    at Function.Module.runMain (module.js:684:10)
    at startup (bootstrap_node.js:187:16)

buildServer.js

const NodeUglifier = require("node-uglifier-es");
const nodeUglifier = new NodeUglifier("./server/index.js");
nodeUglifier.merge().uglify()

//exporting
nodeUglifier.exportToFile("./build/serverRelease.js");
nodeUglifier.exportSourceMaps("./build/sourcemaps/serverRelease.js");
//DONE

Any idea how to solve this? i really need my code to be uglifyed. thank you very much for your support!

el-j avatar Sep 27 '18 15:09 el-j

Same with node-uglifier-es

el-j avatar Sep 27 '18 15:09 el-j

another dead project :/

dagli avatar May 02 '19 11:05 dagli

I don't think you need this project anymore. It should be possible to bundle your project into one file using webpack. Webpack in its latest version includes terser-webpack-plugin which can be used to uglify the result.

krisztianb avatar Oct 25 '21 17:10 krisztianb