Beginner Beginner - 2 months ago 30
Less Question

lessc: command not found (terminal)

I can't use lessc. I have installed npm and node, which are located in usr/local/bin. When I install less via "$ npm install -g less" it is creating a new folder in Users/User/ called "npm-global":

/Users/User/npm-global/bin/lessc -> /Users/User/npm-global/lib/node_modules/less/bin/lessc
less@2.7.1 /Users/User/npm-global/lib/node_modules/less
├── graceful-fs@4.1.6
├── mime@1.3.4
├── image-size@0.5.0
├── source-map@0.5.6
├── errno@0.1.4 (prr@0.0.0)
├── mkdirp@0.5.1 (minimist@0.0.8)
└── promise@7.1.1 (asap@2.0.4)


And then I type lessc and get that "this command is not found". Please help me to solve this problem.

Answer

If this folder

/Users/User/npm-global/bin

is not already in your PATH, you can add it in your ~/.profile file, e.g., by adding a line

export PATH=$PATH:/Users/User/npm-global/bin

at the end of the file. Presumably

/Users/User/npm-global/bin

is meant to be

/Users/$USER/npm-global/bin

which would allow you to simplify it (since the shell is bash, which expands tilde):

export PATH=$PATH:~/npm-global/bin