uglifyjs command not found
Introduction
When you run more command in linux terminal / console, you get the following error message
uglifyjs: command not found
or when using sudo you get the following error message
sudo: uglifyjs: command not found
Solutions to uglifyjs: command not found
How To Fix uglifyjs: command not found in Ubuntu / Debian / Kali Linux / Raspbian
In Ubuntu uglifyjs is provided by node-uglify package.
node-uglify is:
UglifyJS is a JavaScript compressor/minifier written in JavaScript. It also contains tools that allow one to automate working with JavaScript code:
- A parser which produces an abstract syntax tree (AST) from JavaScript code.
- A code generator which outputs JavaScript code from an AST, also providing the option to get a source map.
- A compressor (optimizer) - it uses the transformer API to optimize an AST into a smaller one.
- A mangler - reduce names of local variables to (usually) single-letters.
- A scope analyzer, which is a tool that augments the AST with information about where variables are defined/referenced etc.
- A tree walker - a simple API allowing you to do something on every node in the AST.
- A tree transformer - another API intended to transform the tree.
All the above utilities and APIs are defined in ~6500 lines of code (except for the effective generation of the source-map, which is handled by the source-map module). Compared to alternatives, UglifyJS is pretty small.
NB! This package is deprecated! Please consider using node-uglify-js or uglifyjs instead.
To fix this problem, we can install more using the command below.
sudo apt-get -y install node-uglify
This command might take some time to finish depending on your machine internet connection.
You can also use apt command to install node-uglify.
sudo apt -y install node-uglify
Or if you have aptitude installed you can use the following command.
sudo aptitude install node-uglify
Summary
In this tutorial we learn how to fix uglifyjs command not found error in Ubuntu / Debian / Kali Linux or Raspbian distribution.