UglifyJS using NPM in Windows UglifyJS using NPM in Windows node.js node.js

UglifyJS using NPM in Windows


If you have Windows, Then use the following command

npm -g install uglify-js

the -g flag indicates that this is a global installation and will set the env path.

Working for me. Let me know if it is working for you as well.


Global installs are for command-line utilities.

As you can see the uglifyjs command line utility is dropped into your path, at C:\Users\jcreamer\AppData\Roaming\npm\uglifyjs (which is a link to uglify's bin\uglifyjs as you can see in the output.)

@alessioalex You no longer need admin packages to install a global package. The node MSI installer sets the global default prefix to %APPDATA%\npm, so users have the ability to write to it.

If you're trying to require("uglify-js") in your node program, then you should install it locally, not with the -g. It looks like you're trying to use it as a standalone util, so alessioalex's #2 suggestion is exactly right. Just type uglifyjs to use it, not node uglifyjs.


You can do two things:

  1. Run the command prompt with administrator privileges when installing a global package like this one (right click -> Run as administrator).

  2. Instead of node uglifyjs... use uglifyjs directly. Since it's installed globally you don't need to call it with node in front, that makes no sense.