
Halo, kalau kamu merasa tulisan saya ngebantu, kamu bisa ucapkan terima kasih lewat saweria.
If you feel this website help you, you can donate at saweria.
Node or NPM Not Found When You Use NVM
Auto completion was already exist at
.bashrc,You’re already running this manually
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
- Try run
source ~/.bashrcbut why still cannot runnodeornpmcommand?
Here’s how to solve that problem:
You can check node version that already installed on server using
nvm lsIf nothing installed, you can install nodejs 18,
nvm install lts/hydrogenornvm install v18.16.0for install specific versionIf you already installed node, but still cannot run
nodeornpm, you need to set default node version at server.Run
nvm alias default lts/hydrogenornvm alias default v18.16.0
NPM/Node Not Found When Running Github Actions or Gitlab CI/CD
- You need to add this line at
script
.
.
.
script: |
cd /home/admin/node/
#you need to add this
export NVM_DIR=~/.nvm
#and this one
source ~/.nvm/nvm.sh
npm install --omit=dev
.
.
.
