admin管理员组

文章数量:1333201

  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._pile (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. 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._pile (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?

Share Improve this question asked Aug 13, 2013 at 13:22 Tauri28Tauri28 9081 gold badge18 silver badges30 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

It seems that you've used node instead of uglify in the mand 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.

本文标签: javascriptRunning UglifyJS under nodejs generates cannot find module errorStack Overflow