/lib64/libm.so.6: version `GLIBC_2.27' not found (required by node) - node.js

When I push the code to Github it automatically builds it and start the application on AWS through CodeDeploy with a application_start.sh script file that has the following code:
#!/bin/bash
#give permission for everything in the express-app directory
sudo chmod -R 777 /directory/backend
#navigate into our working directory where we have all our files OR exit
cd /directory/backend || exit
#add npm and node to path
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # loads nvm bash_completion
#install node modules
npm install
npm install pm2#latest -g
#pm2 stop all
pm2 stop backend
pm2 start ecosystem.config.js --env prodaws
This is the error it shows
127 exit code is "File or Directory Not Found"
I have a nother script that runs before the application_start.sh that installs node, I tried installing a more stable version with nvm install --lt but it did not change anything even the node verison

The only solution to this is to change the Operating System, Amazon Linux 2 does not upgrade those libraries to the latest version.
Changing the OS was also suggested by the Amazon Support team check out this article where I described in detail what happened.

Related

Why installed Node.js and Yarn is lost after reconnect to EC2 linux instance

I have on AWS EC2 instance. When I install Node.js with this
AWS tutorial all works fine until i logout current session and log in, than Node.js and Yarn are gone. There is also note from AWS:
The node installation only applies to the current Amazon EC2 session. If you restart your CLI session you need to use nvm to enable the installed node version. If the instance is terminated, you need to install node again. The alternative is to make an Amazon Machine Image (AMI) of the Amazon EC2 instance once you have the configuration that you want to keep, as described in the following topic.
Is it possible to install Node.js so it is available in another session? I installed zsh and that works for all sessions.
I also created simple script that will install Node.js and Yarn. Commands in this script are from AWS Tutorial page that I mentioned early. It will install Node.js and Yarn, show that all works (it shows Yarn version and message from node command), but when I type npm --version or yarn --version it will shows message zsh: command not found: yarn (or similar message for npm).
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
. ~/.nvm/nvm.sh
nvm install --lts
node -e "console.log('Running Node.js ' + process.version)"
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
echo "installing YARN !!!!! "
npm install yarn --global
Why is my script not working?
If you use manual from AWS how to install Node.js than instalation is only made in your home directory that lives only for current session. To install Node.js and Yarn I used this post: https://stackoverflow.com/a/35165401/78935
Or you could simply use this:
sudo curl --silent --location https://rpm.nodesource.com/setup_16.x | bash
sudo yum -y install nodejs
sudo npm install yarn --global
yarn --version

How to install npm after it uninstalled itself?

I was recommended to run sudo npm install -g npm and so I did, now npm is gone!
It doesn't exist in the directory either /usr/local/lib/node_modules/.
Is there a way to install it back?
edit
I have node installed v14.17.0
you can use NVM(nodejs version manager) simply by running this command :
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
and
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
now you can download any version of nodejs and use it into the single project or globally without problems
if you need to download any version you can do it by the comand :
nvm install 14
now you have npm and node 14, but if you need to use it into the project you can do it by the command : nvm use 14
now you can switch between node(or npm) versions without any problem
npm comes with nodejs, you can just install nodejs using your OS.
See the link below
https://nodejs.org/en/download/
Once you install nodejs, npm will be installed.

By restarting system terminal does not recognize npm and node commands

I have installed node and npm by nvm; At the end of instaling nvm, below message was shown:
Close and reopen your terminal to start using nvm or run the following to use it now:
export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
So I run that command and use nvm, install node versions and npm.
But when I restart my system, I have to run above command otherwise terminal says command not found.
What is the problem and how can I fix it?
The nvm installation should have added a couple of lines to your shell initialization script that makes sure to initialize nvm in every new shell, but for some reason this seems to have not happened.
Assuming that you're using bash, try adding these lines to your ~/.bash_profile
export NVM_DIR="$HOME/.nvm"
. "$(brew --prefix nvm)/nvm.sh"
Then start a new terminal session and see if that does the trick.
Another thing that could be worth double-checking is to see if you have any installed node version aliased as the default one. I'm not sure what nvm does if you don't have a default version specified (if that's even possible). Run nvm ls and see you you have default pointing to any installed version of Node. If not, then set that up by running nvm alias default [version-number].

npm install zsh: command not found: npm

I just reinstalled node on my laptop and trying to install packaged in project. I installed node via brew and Im using MacOS.
npm install
zsh: command not found: npm
The solution below actually solved my issue
https://superuser.com/questions/1403007/zsh-npm-node-nvm-command-not-found-after-installing-ohmyzsh
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"
# This loads nvm bash_completion
this line of code on your .zshrc file to do that type vim ~/.zshrc than add the following lines in the bottom and to save the file click ctrl than press :wq! to save file in vim you can also use nano
Your binaries for npm are in /usr/local/share/npm/bin. Is this in your path environment variable?
If not export it at ~/.zshrc with export PATH=/usr/local/share/npm/bin:$PATH.
For me, I encountered the same issue as you did.
How I fixed:
First, checking whether npm is installed or not by checking its version:
npm --version
If the terminal still shows no npm not found, then type:
nvm install --lts
This command will trigger updating node package manager to the latest version.
Hope it helps.
You should run nvm use node every time you startup a new terminal.

Running npm install on Ubuntu with Octopus Deploy

We are using Octopus deploy to deploy an angularjs app. I'm running a post deployment script (bash) and in there I try to do npm install. This doesn't work, I get an error
npm: command not found
However if I login to the linux box as the Octopus user, go to the directory that Octopus Deploy is trying to run the script from, I am able to run npm install without error.
I've confirmed its the right user (running whoami before npm install in the post deployment script).
I've tried adding the npm executable to my PATH variables which didn't work. I've also put the full path to npm in my script which gives me a new error
/usr/bin/env: ‘node’: No such file or directory
Please run the following command as octopus user to access npm for other users.
n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local
Or use nvm to install node
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.33.2/install.sh | bash
source ~/.bashrc
source ~/.profile
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  
nvm ls-remote
nvm install 8.10.0 
node --version
npm --version
which node
n=$(which node);n=${n%/bin/node}; chmod -R 755 $n/bin/*; sudo cp -r $n/{bin,lib,share} /usr/local
https://github.com/creationix/nvm
If you are installing new node version, please do the following steps.
nvm list will show all installed node versions
nvm use v8.10.0
nvm alias default v8.10.0 set default node version for current user

Resources