node.js - 错误 : uglifyjs not found

标签 node.js npm minify uglifyjs

我想通过命令行自动缩小文件夹。然后我安装了 npm install -g minify-all,然后是 minify-all/opt/myapp/。它给出:

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)

有人知道怎么解决吗? minify-all 是正确的包吗?

编辑 1: 我试过 sudo npm install uglify-js -g

/usr/local/bin/uglifyjs -> /usr/local/lib/node_modules/uglify-js/bin/uglifyjs
/usr/local/lib
└─┬ uglify-js@3.0.11 
  ├─┬ commander@2.9.0 
  │ └── graceful-readlink@1.0.1 
  └── source-map@0.5.6 

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

async@0.2.10 node_modules/uglify-js/node_modules/async -> node_modules/swig/node_modules/async
flapper-news@0.0.0 /opt/myapp
├─┬ swig@1.4.2
│ └─┬ uglify-js@2.4.24 
│   └── source-map@0.1.34 
└─┬ uglify-js@3.0.11 
  ├─┬ commander@2.9.0 
  │ └── graceful-readlink@1.0.1 
  └── source-map@0.5.6 

但是,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)

我不必使用uglify-js,我只是想最小化jscss。还有其他选择吗?

最佳答案

如果你真的使用uglify,你需要去安装uglify-js: https://www.npmjs.com/package/uglify-js相反。

npm install uglify-js -save--dev

关于node.js - 错误 : uglifyjs not found,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44192936/

相关文章:

webpack - 如何关闭 webpack 中的 babel 缩小?

python - 在 webapp2 中部署时缩小/压缩 javascript 和 css?

node.js - 如何让 Firebase Functions 充当用户而不是管理员?

javascript - 从种子/键创建大型数组/数据

npm - 设置NPM预发布缩小脚本

node.js - 为 node.js 模块创建依赖 docker 的测试是否可以接受?

perl - 如何缩小 Perl 脚本?

javascript - Passport.js - req.isAuthenticated 不是函数

node.js - 启动时运行并监控redis和node.js进程

node.js - 使用 simple-git 的 nodejs 浅 git 克隆