Running UglifyJS in node.js cannot find module error

  • Running node.js v0.10.15 on windows 7 - installed VIA node -v0.10.15-x86.msi.
  • The latest UglifyJS2 library has been loaded.
  • The generated batch file with the 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?

+4
source share
1 answer

It seems that you used node instead of uglify on the command line. Since uglifyjs is a native CLI, you do not need to call node. I believe that you need this to be installed globally for the intended purpose.

npm install uglify-js -g

then

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

must work.

+6
source

Source: https://habr.com/ru/post/1496805/


All Articles