4
  1. Running node.js v0.10.15 on windows 7 - installed VIA node-v0.10.15-x86.msi.
  2. Downloaded latest UglifyJS2 library.
  3. Created batch file with syntax:

node "path\to\uglifyjs\bin\uglifyjs" -o "file.min.js" "file.js"

Getting error:

module.js:340
   throw err;
Error: Cannot find module 'source-map'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (D:\Projektid\Tools\uglifyjs\tools\node.js:9:21)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

What could be the problem?

1 Answer 1

6

It seems that you've used node instead of uglify in the command line. Since uglifyjs is its own CLI, you don't need to call on node. I believe you need to have this installed globally to work as intended.

npm install uglify-js -g

then

uglifyjs "path\to\uglifyjs\bin\uglifyjs" -o "file.min.js" "file.js"

should work.

Sign up to request clarification or add additional context in comments.

2 Comments

Got it working with command uglifyjs -o "file.min.js" "file.js" instead. Thanks.
uglifyjs "myOriginalFile.js" -o "File.min.js"

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.