12

I installed nodejs from nodejs.org on my windows box.

The path to node is C:\Program Files (x86)\nodejs\node.exe

I can run node in command prompt correctly, my question is...I cloned uglifyjs to C:\gitrepos\uglifyjs\

Now I am trying to figure out how to get things setup to just run something like

node uglifyjs -o inputfile.min.js inputfile.js

What has to happen to allow me to do that?

1
  • I'd put a .bat file or so in your path that passes its arguments to node <path to uglifyjs> <arguments> - however, I'm not good enough at batch scripting to be able to tell you how to do this. Commented Nov 22, 2011 at 15:14

3 Answers 3

52

For you to run any NodeJS app in any environment(folder). Do the following

  1. Install the app globally

    npm install uglify-js -g 
    
  2. Exit and re-open the command prompt

  3. Run uglifyJS without node command

    uglifyjs [options] filename
    
Sign up to request clarification or add additional context in comments.

2 Comments

This is exactly what I was looking for thank you, was missing the -g on previous attempts installing from npm.
Some older versions of Node does not set up the PATH probably, in which case you will need to upgrade to the newest version.
11

You can run it by :

node C:\gitrepos\uglifyjs\bin\uglifyjs -o inputfile.min.js inputfile.js

5 Comments

That works, but I was wondering if there is a place you can add either a path variable or something to just say uglifyjs instead of having to include the whole path...
Create an alias or a batch file as shown here : rhyous.com/2010/10/20/…
I found that I had to run uglifyjs.cmd from my profile for it to work i.e. C:\Users\me\AppData\Roaming\npm\uglifyjs.cmd
I have minified my .js file using this command, bur can anybody guide me how to minify .css file ??
"uglifycss c:/wamp/project1/app.css -o c:/wamp/project1/app.min.css" does not work
3

You could just add the C:\gitrepos\uglifyjs\bin path to your...path environment variable.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.