Add express to Path in NodeJS - node.js

Hi im working on NodeJS with express in Mac OS,
After install:
with brew: https://changelog.com/posts/install-node-js-with-homebrew-on-os-x
Shows me:
/Users/dortiz/.npm-packages/bin/express -> /Users/dortiz/.npm-packages/lib/node_modules/express-generator/bin/express-cli.js
And if I will execute:
daortiz:~ dortiz$ express
-bash: express: command not found
But:
/Users/dortiz/.npm-packages/bin/express
Its working,
Im trying to export a path with
export PATH=$PATH:/Users/dortiz/.npm-packages/bin/
Its success, but if I close and reopen the terminal don't works command
But doesn't works, any one know what I doing wrong?

Using export sets environment variables for current shell only. Once shell is terminated environment variables for that shell no longer exist.
In order to set environment variables for all shell that are initiated you should put them in ~/.bash_profile as pointed by mailo.

You need to add the line to a file that will be sourced on login, for example: ~/.bash_profile

Related

Flutter command not found inside a shell script

I am creating a shell script to run on my Linux machine when I want to create a new flutter project.
But when I try to put flutter create appName inside the shell script it gives me
./flutter.sh: line 9: flutter: command not found
I added flutter to path so I can run flutter create appName from the terminal with no problem at all.
Thank you for your help.
The reason for command not found is cause, you have not given the full path of the flutter program or forgotten to reinit the environment in which you set the PATH Var. To set PATH variable, edit the hidden file .bashrc and append the flutter program's fullpath to PATH variable. Then run the following program after saving the .bashrc file.
source ~/.bashrc
That will reload the .bashrc environment variables.
Alternatively, I suggest you do the following though, for better programming practice.
Do execute this command to find fullpath of flutter program whereis flutter. Then specify the fullpath/flutter in the shell script. It's always good programming practice to specify fulllpath in programs.
example in shellscript - replace the flutter command with this line: /usr/bin/flutter

my fedora PATH variables went out, how to restore them

I wanted to add php to envirmonment variables
So I wrote:
export PATH=/opt/lampp/bin/
Then I discovered that this was wrong because it relaced the envirmonment variable PATH with only ( /opt/lampp/bin/ ).
Is there a way to restore the path to an earlier version?
restart your shell / exit your terminal. unless you edit your .bashrc file the changes to environment variable via the export command are not permanent

Cannot run Swift under Ubuntu after closing the terminal

I am trying to run the Swift compiler under Ubuntu. I followed this tutorial: https://itsfoss.com/use-swift-linux/ and everything seemed to work fine. I was able to run swift under Ubuntu.
However, when I closed the terminal, I was not able to run Swift anymore. The program was not found until I installed it again. I could not find any answers to this question as there aren't many people running Swift under Ubuntu.
It's not uninstalled, you just don't have the environment variables set up anymore, so Bash can't find the path to Swift. You can change that by exporting the appropriate environment variables in your .bashrc file.
When you followed the tutorial, you ran the following command:
export PATH=path_to_swift_usr_bin:$PATH
This command adds the path to the swift binary to your PATH environment variable. The PATH variable holds a list of places where Ubuntu will look for programs to run from the command-line. So if the Swift executable is not in one of the places listed in the PATH, your terminal will never find it.
There is a file in your home folder (the folder ~, which is an abbreviation for /home/username, where username is your username) named .bashrc, which runs whenever you open a new terminal window. If you need an environment variable to be available whenever you open the terminal, you should add the export line for that variable to your .bashrc.
In this case, your .basrhc should contain the same line above.
The important thing to remember is that your environment variables are not preserved between command-line sessions, so if you want to have an environment variable available every time you use the command-line, it needs to be defined in your .bashrc.

Nodejs module oracled cannot find LD_LIBRARY_PATH

I'm getting the following error in my nodejs script using the oracledb module on a Centos 6 VM:
Error: libclntsh.so.11.1: cannot open shared object file: No such file or directory
We're using the full Oracle client. My google searches have led me to LD_LIBRARY_PATH being the problem. It is set in /etc/profile.d/ in an oracle script, and I can see it in my linux user's env output. But when I check process.env within the node script, LD_LIBRARY_PATH is simply not there. (If I add other variables to my /etc/profile.d script, those test variables appear in process.env)
The other weirdness is that when I run the script as root, the variable gets set properly and the script executes as expected.
So why is LD_LIBRARY_PATH disappearing when my non-root user runs the script?
You didn't explain how you are invoking the script. If you are sudo-ing, do you need to call a shell script that sets LD_LIBRARY_PATH before invoking node?

customed command not found in a new terminal

everyone.
I had a basic question want to consult, about the environment variable setting.
After closed my one existed terminal which could execute compile(make) and do customed(mksdboot) command, i can't do mksdboot command anymore(I had execute a predefined setting environment variable shell script i.e. $ . ./arndale_envsetup.sh again) in the new terminal.
Cause i am a beginner in Linux, i am not very clearly about the environment variable setting rules.
i had tried to 'su' or 'sudo' to execute mksdboot, but no luck:(
ps. I had another project needs to compile in my PC(i didn't export PATH to .bashrc, only execute export PATH when i open a new terminal every time), may it efforts the original project's environment variable?
thanks.
[UPDATED]
i tried using $source ./arndale_envsetup.sh, relative commands worked finally.
but i still did't figure out the reason between work or not work. >"<
The command
history
will list what your previous commands where.
This might give you a pointer what set the path in the way you needed it.
You could also try to see where you command is via
locate mksdboot

Resources