lessc: command not found - node.js

I'm on OS X.8 and a newbie at Node & LESS. I thought I installed lessc earlier and when I go to /usr/local/bin I see lessc
but for the life of me, I can't run it. Anytime I do run it, I see
-bash: lessc: command not found
So I've tried the tip here which has the following:
ln -s ~/.npm/less/1.3.3/package/bin/lessc my/local/dir
My local dir happens to be on a second drive on my laptop, here's the path:
/Volumes/Mac17/Users/denis2/Sites/staging/assets/less
With all that said, I try and run:
lessc boostrap.less
and still get
-bash: lessc: command not found
I'm totally lost here and any help would be tremendous.

Just follow the steps :
Make lessc executable by your user(permission denied means you dont have permission to run) like chmod 755 lessc
Export the location of lessc into the PATH like export PATH=$PATH:/home/user/folder/path/less/bin (where lessc is present)
Use lessc lessc boostrap.less
You should put PATH export in environment so that you dont have to do it every time you login See here :
Setting environment variables in OS X?

If you enter just lessc, it is searched in the $PATH. For security reasons, the current directory is not in the $PATH. Try
./lessc bootstrap.less
or, if that doesn't work, simply
~/.npm/less/1.3.3/package/bin/lessc bootstrap.less
If you get a Permission Denied error then, you may need to mark the file as executable. Use
chmod a+x ~/.npm/less/1.3.3/package/bin/lessc
to do that. You may also need to call node directly, if it isn't in your $PATH.

Related

Installing rclone according to the official instructions but permission denied

Noob question, but hear me out
So I installed rclone word-for-word according to this (https://rclone.org/install/)
However, when I got around to rclone config the terminal returned 2020/02/28 11:37:29 Failed to load config file "/home/myUser/.config/rclone/rclone.conf": open /home/myUser/.config/rclone/rclone.conf: permission denied
In an attempt to fix this I ran chmod u+x "/home/myUser/.config/rclone/rclone.conf" which returned chmod: changing permissions of '/home/myUser/.config/rclone/rclone.conf': Operation not permitted
Then I ran the same command prefixed with sudo which seemed to work. Yet after running rclone config again the same permission denied error appeared. What should I do? What did I do incorrectly during install? I just want to be able to run rclone config without having to use sudo.
Unrelated side note I had a similar experience with Anaconda in which I can't run the command for opening the program without sudo but as I ran the command with it the launcher appears with an error message which I can't remember exactly but it ran along the lines of: "Cannot run in sudo mode, please do it again in user mode." Funny Catch-22 if you ask me. I ended up uninstalling it.
Solution: set the permissions of rclone.conf to chmod 777. I changed the whole folder and its files using sudo chmod -R 777 /home/myUser/.config/rclone/ for good measure. Now I can finally retry installing Anaconda.

How to run executables from terminal in Linux without entering the entire PATH

I'm trying to activate android studio directly from terminal (./studio.sh)
the installation dir is /usr/local/android-studio
and inside there's a bin folder with the script studio.sh
for that I've vi'd ~/.bashrc to include the following line:
export PATH=$PATH:/usr/local/android-studio/bin
When I do echo $PATH i do see the path above appended to the rest of the path
(/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/local/android-studio/bin)
Yet when I run ./studio.sh it prompts me with No such file or directory
Needless to say, if i cd /usr/local/android-studio/bin and then ./studio.sh it works fine
running debian (jessie 'edition')
I simply needed to do studio.sh without the ./
Thanks for ZanCoul for providing the answer.

'express' command not found on mac

Definitely a noob question so please don't judge but this has been bothering me for a while.
No more how many times I run $ sudo npm install -g express-generator or $ npm install express -g, everything seems to install but the command $ express still doesn't exist.
I'm running fish shell. Also, I'm assuming this is an issue coming from my PATH file, but I'm lost on if that's .bash_profile or .bashrc.
My .bash_profile has the three lines in it:
export PATH=/usr/local/bin:$PATH
export PATH=/Users/username/.node/lib/node_modules/express-generator/bin/express:$PATH
export PATH=/Users/username/.node/bin/express:$PATH
and my .bashrc file has nothing regarding node in it.
When express installs, it returns:
/Users/username/.node/bin/express -> /Users/username/.node/lib/node_modules/express-generator/bin/express
/Users/username/.node/lib
but when I command which node it returns
/usr/local/bin/
When I try to run $ls -l /usr/local/bin/express it returns:
ls: /usr/local/bin/express: No such file or directory
Cannot find the diagnosis of why the express command won't work after installation.
If you are running fish, your .bash_profile is ignored, of course!
The preferred way to add /Users/username/.node/bin/ to your $PATH in fish is like so:
set -U fish_user_paths $fish_user_paths /Users/username/.node/bin/
that's just something you run once, at the command line - not something you put in a startup file.
If you prefer to use startup files, you can instead modify your ~/.config/fish/config.fish like so:
set PATH $PATH /Users/username/.node/bin/
From the symlink after the install, the express binary should be available in the /Users/username/.node/bin directory. The reason you can't use the binary is because the /Users/username/.node/bin directory is not in your $PATH. Whats in the $PATH is the binary itself.
When you add a directory to your $PATH, you can execute binaries from within the directory. Currently, your $PATH points to the /Users/username/.node/bin/express which does not have any binaries within it. You should correct it to:
export PATH=/Users/username/.node/bin:$PATH

teach me how to set up a path correctly

I installed casperjs by npm install command on my mac os x.
But, when I try using casperjs in command line, it gives me the error below.
$ casperjs cas.js
-bash: /usr/local/bin/casperjs: No such file or directory
I checked if casperjs is installed by using which command.
The result is below.
$ which casperjs
-bash: /Users/Hayato/.nodebrew/current/bin/casperjs
I think what I need to do is to setup a path in a different way so that when I run "casperjs test.js", it runs "/Users/Hayato/.nodebrew/current/bin/casperjs" instead of "/usr/local/bin/casperjs".
But, I'm not familiar with this kind of terminal task, and don't know how to do this.
Please could anyone teach me how to setup a path correctly?
Thanks!
If you want to use casperjs in the directory you specified, add this to your ~/.bash_profile
export PATH=/Users/Hayato/.nodebrew/current/bin/:$PATH
Save the file
That will add all scripts in the /Users/Hayato/.nodebrew/current/bin directory to your path.
After that.. close the terminal and then reopen it:
You can check the path by doing:
echo $PATH
You should see the path you just added.
Then when you do the following:
which casperjs
it should use the new location.
Let me know if this works for you!
But, the issue may be something deeper, did you get errors when you installed casperjs via brew?
You may want to try linking it again using
brew link casperjs
If that doesn't work you may have some permission issues.
Check out these previously answered questions:
brew link didn't complete
Fixing homebrew permissions

Modifying $PATH variable

Trying to install node.js.
Did brew install node
It seems to have worked.
However, received this message upon its completion
Homebrew installed npm.
We recommend prepending the following path to your PATH environment
variable to have npm-installed binaries picked up:
/usr/local/share/npm/bin
Ok ... so, I open my bash_profile...
And this is what I have in it:
export PATH="/usr/local/bin:/usr/local/sbin:~/bin:$PATH"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
Trying to understand how to modify it correctly so I won't ruin it ...
Do I add /usr/local/share/npm/bin like this
export PATH="/usr/local/bin:/usr/local/sbin:~/bin/usr/local/share/npm/bin:$PATH"
If not, what is the correct way to add that path?
Thank you for any help provided!
PS. let me know if there is any additional information I could have provided
EDIT
upon seeing which npm in macedigital's answer, I ran that ...
and got this: /usr/local/bin/npm
and that was before I did the second answer (ie, ThiefMaster's answer).
ran which npm again ...
and got the same answer as before ...
i did echo $PATH and got this:
/Users/name/.rvm/gems/ruby-1.9.3-p374/bin:/Users/name/.rvm/gems/ruby-1.9.3-p374#global/bin:/Users/name/.rvm/rubies/ruby-1.9.3-p374/bin:/Users/name/.rvm/bin:/usr/local/share/npm/bin:/usr/local/bin:/usr/local/sbin:~/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/usr/local/git/bin
So, it looks like I already had it installed?
Therefore, how do I handle the answers? I hate leaving it unresolved since both of you were so helpful and I feel bad that I asked without providing echo $PATH information since that would have told you that I had it installed ...
EDIT 2
ls -la /usr/local/share/npm/bin gets this:
ls: /usr/local/share/npm/bin: No such file or directory
which -a npm gets this: /usr/local/bin/npm
EDIT 3
ls -a /usr/local/bin/npm gets this: /usr/local/bin/npm
there's no timestamp...
Short answer, do this (notice the additional colon I inserted):
export PATH="/usr/local/share/npm/bin:/usr/local/bin:/usr/local/sbin:~/bin:$PATH"
The $PATH environment variable is colon separated list of directories to look in if you want to run a command without a fully qualified path (e.g. running npm instead of having to type /usr/local/share/npm/bin/npm).
You can try this from a terminal before actually saving the change in bash_profile. If everything is good, which -a npm will show you all fully qualified path(s).
UPDATE
It is not necessary to modify the $PATH variable in order to use npm. What homebrew install recommends instead is to add the directory where npm-installed binaries are stored to the $PATH variables, so its more convenient to use them from the command line later on.
Node modules like phantomjs, phonegap, express, etc. provide binaries which after the change are available on the command prompt without having to type the full path.
The cleanest solution is adding the following between the two lines you posted:
export PATH="/usr/local/share/npm/bin:$PATH"
That way everything stays readable and you prepend it to PATH just like the program suggested it. And if you ever want to undo the change you just remove that line instead of editing a possibly long line.
In PATH ORDER IS IMPORTANT. So anything before desired npm version will still cause problems.
#adding in first place of the path, before anything else
export PATH=/usr/local/bin:otherPathEntries:$PATH
assuming that version of npm You want is in /usr/local/bin, to check all use 'which -a npm'

Resources