Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

npm command not found and unable to look up myuser@github.com #70

Closed
rahulserver opened this issue Jul 12, 2020 · 6 comments
Closed

npm command not found and unable to look up myuser@github.com #70

rahulserver opened this issue Jul 12, 2020 · 6 comments

Comments

@rahulserver
Copy link

rahulserver commented Jul 12, 2020

Here is my main.yml

name: Node Github CI

on:
  push:
    branches:
      - master

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
    - name: Node Js
      uses: actions/setup-node@v1
       
    - name: SSH and deploy node app
      uses: appleboy/ssh-action@master        
      with:
        host: ${{ secrets.SERVER_IP }}
        username: ${{ secrets.USERNAME }}
        key: ${{ secrets.SERVER_KEY }}
        script: |
          service myservice stop
          cd leancrm-backend
          git pull git://myuser@github.com/mycmp/myapp-backend.git master
          npm install
          service myservice start

It gives this error:

======CMD======
service myservice stop
cd myapp-backend
git pull git://myuser@github.com/mycmp/myapp-backend.git master
npm install
service myservice start

======END======
err: fatal: Unable to look up myuser@github.com (port 9418) (Name or service not known)
err: bash: line 3: npm: command not found
==============================================

So its not connecting to git and also not able to find npm. I am sure that these exist on the server as I use them regularly.
How do I make this work?
Related SO post: https://stackoverflow.com/questions/62863080/github-actions-err-bash-line-3-npm-command-not-found

@MMortari
Copy link

Hi bro, i'm having the exact same problem but with yarn, tell us if you figure out how to solve it.

@alvinl
Copy link

alvinl commented Jul 27, 2020

It appears that the script isn't executing my .bashrc properly as that's the only way to load Node and NPM onto my $PATH. I was able to get around this by manually calling NVM in the script before doing any NPM or Node commands.

script: |
   git pull
+  export NVM_DIR="$HOME/.nvm"
+  [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
   nvm install --lts
   node -v
   npm -v

@MMortari
Copy link

@alvinl it worked perfectly for me, thanks

@appleboy
Copy link
Owner

appleboy commented Aug 3, 2020

Duplicated of #21

@appleboy appleboy closed this as completed Aug 3, 2020
feilongjump pushed a commit to feilongjump/toy that referenced this issue Dec 4, 2020
@fcbuz2000
Copy link

npm: command not found
Reason:
I use nvm for the server node environment, and nvm will not install the node environment in the /usr/local/bin/ directory, so that sudo can't find the corresponding instructions, and finally create a soft connection to solve

sudo ln -s "$NVM_DIR/versions/node/$(nvm version)/bin/node" "/usr/local/bin/node"
sudo ln -s "$NVM_DIR/versions/node/$(nvm version)/bin/npm" "/usr/local/bin/npm"
sudo ln -s "$NVM_DIR/versions/node/$(nvm version)/bin/pm2" "/usr/local/bin/pm2"

you can test "sudo npm -v"

https://blog.csdn.net/weixin_40599109/article/details/110825357

@azamatos
Copy link

azamatos commented Jul 1, 2023

npm: command not found Reason: I use nvm for the server node environment, and nvm will not install the node environment in the /usr/local/bin/ directory, so that sudo can't find the corresponding instructions, and finally create a soft connection to solve

sudo ln -s "$NVM_DIR/versions/node/$(nvm version)/bin/node" "/usr/local/bin/node" sudo ln -s "$NVM_DIR/versions/node/$(nvm version)/bin/npm" "/usr/local/bin/npm" sudo ln -s "$NVM_DIR/versions/node/$(nvm version)/bin/pm2" "/usr/local/bin/pm2"

you can test "sudo npm -v"

https://blog.csdn.net/weixin_40599109/article/details/110825357

The best answer, thank u bro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants