12

I'm trying to use uglifyjs via command line, and it's not going well.

I've tried many variations of $ [sudo] npm install uglify-js -g, but in all cases, when I try to run uglifyjs as a command $ uglifyjs it says command not found.

In every case, it seems like uglify gets installed. Version 2.4.0 is listed under $ npm list -g as being installed.

I'm running: node v0.10.17 (installed via pkg from node homepage ) npm v1.3.8

I've restarted a couple of times after various installations, but I'm not getting any success.

/usr/local/share/npm/bin/uglifyjs -> /usr/local/share/npm/lib/node_modules/uglify-js/bin/uglifyjs
[email protected] /usr/local/share/npm/lib/node_modules/uglify-js
├── [email protected]
├── [email protected]
├── [email protected] ([email protected])
└── [email protected] ([email protected])
Andrews-MacBook-Pro:node_modules andrewheins$ uglifyjs
-bash: uglifyjs: command not found

Any ideas?

andrewheins
  • 273
  • 1
  • 2
  • 8
  • 2
    Seems that /usr/local/share/npm/bin/uglifyjs is where the program was installed and /usr/local/share/npm/bin/ is not in your PATH environment variable. What happens if you issue as a command /usr/local/share/npm/bin/uglifyjs ? I am not familiar with this software or your set-up, this is just reasoning from general principles. – micans Aug 28 '13 at 12:48

3 Answers3

23

My problem was that I installed uglifyjs, and not uglify-js. uglifyjs does not include the binary. Just leaving this here if someone else is stuck the same way.

sudo npm install -g uglify-js

3

Using @micans comment above, and this answer, I was able to get uglify working by adding export PATH=$PATH:/usr/local/share/npm/bin/ to my .bash_profile. Thanks all!

andrewheins
  • 273
  • 1
  • 2
  • 8
0

I had the same problem in my Linux Mint installation. I resolved it just executing the follows commands:

sudo apt-get update
sudo apt-get upgrade
Greenonline
  • 2,235
  • 11
  • 24
  • 30