I'm trying to improve my node script that essentially converts a modified LESS file to CSS. It ends up making a bunch of redundant CSS so I wanted to use another module to "minify" it. I tried the official LESS one as well as what seems to be a third party but neither work.
Both work via. the command line just fine, however whenever I try and import them in the script, it throws an error:
module.js:338
throw err;
^
Error: Cannot find module 'clean-css'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (M:\Sped\Custom CSS\compile.js:12:16)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
I've attempted to install them multiple times both with and without the -g flag (not entirely sure what that even does).
I've found other questions like this but they seem to be the other way around in that they can import them in the script but no command line use, and they were on Mac or Linux.
Not sure if it makes much difference but I'm on Windows 10 64-bit.
Is anyone able to tell me what I can do to resolve this issue?
node compile.js, it compiles the CSS from the LESS file creating a new file. I have 2 differentrequirestatements in the script that work fine.npm install clean-cssin your CMD, it should make a node_modules folder in the folder your project is in. That's where Node.js pulls it's 'requires' from-gflag and running it from the directory of the other modules.