Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: uglifyjs not found

I want to minify a folder automatically by a command line. I then installed npm install -g minify-all, then minify-all /opt/myapp/. It gives:

minify-all /opt/myapp/
found file: /opt/myapp/addin_online/css/Common.css
/usr/local/lib/node_modules/minify-all/node_modules/node-minify/lib/node-minify.js:104
          throw new Error(bin + ' not found !');
          ^

Error: uglifyjs not found !
    at getPath (/usr/local/lib/node_modules/minify-all/node_modules/node-minify/lib/node-minify.js:104:17)
    at Object.compress (/usr/local/lib/node_modules/minify-all/node_modules/node-minify/lib/node-minify.js:132:27)
    at Object.minify (/usr/local/lib/node_modules/minify-all/node_modules/node-minify/lib/node-minify.js:83:10)
    at /usr/local/lib/node_modules/minify-all/index.js:30:13
    at /usr/local/lib/node_modules/minify-all/index.js:14:13
    at Array.forEach (native)
    at walk (/usr/local/lib/node_modules/minify-all/index.js:10:36)
    at /usr/local/lib/node_modules/minify-all/index.js:16:13
    at Array.forEach (native)
    at walk (/usr/local/lib/node_modules/minify-all/index.js:10:36)

Does anyone know how to fix this? Is minify-all the right package to use?

Edit 1: I tried sudo npm install uglify-js -g

/usr/local/bin/uglifyjs -> /usr/local/lib/node_modules/uglify-js/bin/uglifyjs
/usr/local/lib
└─┬ [email protected] 
  ├─┬ [email protected] 
  │ └── [email protected] 
  └── [email protected] 

And sudo npm install uglify-js -save--dev under /opt/myapp/

[email protected] node_modules/uglify-js/node_modules/async -> node_modules/swig/node_modules/async
[email protected] /opt/myapp
├─┬ [email protected]
│ └─┬ [email protected] 
│   └── [email protected] 
└─┬ [email protected] 
  ├─┬ [email protected] 
  │ └── [email protected] 
  └── [email protected] 

However, minify-all /opt/myapp/ still shows:

found file: /opt/myapp/addin_online/css/Common.css
/usr/local/lib/node_modules/minify-all/node_modules/node-minify/lib/node-minify.js:104
          throw new Error(bin + ' not found !');
          ^

Error: uglifyjs not found !
    at getPath (/usr/local/lib/node_modules/minify-all/node_modules/node-minify/lib/node-minify.js:104:17)
    at Object.compress (/usr/local/lib/node_modules/minify-all/node_modules/node-minify/lib/node-minify.js:132:27)
    at Object.minify (/usr/local/lib/node_modules/minify-all/node_modules/node-minify/lib/node-minify.js:83:10)
    at /usr/local/lib/node_modules/minify-all/index.js:30:13
    at /usr/local/lib/node_modules/minify-all/index.js:14:13
    at Array.forEach (native)
    at walk (/usr/local/lib/node_modules/minify-all/index.js:10:36)
    at /usr/local/lib/node_modules/minify-all/index.js:16:13
    at Array.forEach (native)
    at walk (/usr/local/lib/node_modules/minify-all/index.js:10:36)

I don't have to use uglify-js, I just want to minimise js and css. Is there any other options?

like image 448
SoftTimur Avatar asked May 26 '17 03:05

SoftTimur


1 Answers

If you really use uglify, you need to go install uglify-js: https://www.npmjs.com/package/uglify-js instead.

npm install uglify-js -save--dev

like image 173
Xin Avatar answered Nov 14 '22 20:11

Xin