I am trying to install Node and Less on Ubuntu 12.1. Installing appears to work ok and I can see there is a Less folder created when I install Less using "sudo npm g install less" in:
/usr/local/lib/node_modules
However when I run "lessc -v" I get the below:
module.js:340
throw err;
^
Error: Cannot find module 'less'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (/usr/bin/lessc:8:12)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
Any ideas where I am going wrong?
You should create symlink to node modules directory into your home directory.
$ ln -s /usr/lib/node_modules/ ~/.node_libraries
(if you installed node from source it'll be /usr/local/lib/node_modules)
Modules installed in the "global scope" (which is what happens when you use npm -g install
or install node modules from Ubuntu repositories, for example - sudo apt-get install node-less
) are loaded by populating the NODE_PATH
environment variable.
Packages installed from Ubuntu repositories handle this automatically, but if you install manually you have to set this yourself. In your case, you'd need to add the following command to your .bash_profile
:
export NODE_PATH="$NODE_PATH:/usr/local/lib/node_modules"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With