在共享主机上使用带位桶管道的ssh时找不到npm命令 [英] npm command is not found when ssh with bitbucket pipelines on shared hosting

查看:120
本文介绍了在共享主机上使用带位桶管道的ssh时找不到npm命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经按照此处.

我自己SSH到服务器时,一切正常.但是我创建了一个脚本,用于部署我的应用程序并通过位桶管道调用它.除npm install之外,其他所有东西都可以正常工作(composer installphp artisan migrate等).错误消息是

Everything works fine when I ssh to the server myself. But I've created a script that deploys my application and call it via bitbucket pipelines. Everything else works fine (composer install, php artisan migrate etc.), except npm install. The error message is

./deploy:第26行:npm:未找到命令

./deploy: line 26: npm: command not found

在bitbucket-pipelines.yml中,我这样称呼我的脚本:

In bitbucket-pipelines.yml I call my script like this:

- step:
    script:
      - ssh user@ip_address ./deploy

当我自己调用脚本时,一切正常.问题仅在于位桶流水线.我不知道为什么会这样:(.

When I call the script by myself everything works. The problem is only with bitbucket pipelines. I have no clue why this happens :(.

推荐答案

正在运行which composer显示至少没有从您的假定位置(即~/composer)拾取composer命令.目录相反,它是在/opt/cpanel/composer/bin/composer中找到的.

Running which composer revealed that at least composer command is not getting picked up from your assumed location i.e., ~/composer dir. Instead, it was found in /opt/cpanel/composer/bin/composer.

which npm返回以下内容:

no npm in (/usr/local/cpanel/3rdparty/lib/path-bin:/usr/local/jdk/bin:/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/usr/local/bin:/usr/X11R6/bin:/root/bin:/opt/bin:/opt/cpanel/composer/bin:/home/handmast/.local/bin:/home/handmast/bin)

现在,由于您能够手动运行命令npm,因此您只需要弄清npm的运行路径,并确保该路径已明确地添加到用户的 ~/.bashrc文件,一切正常.您需要执行此操作,因为根据您的观察,ssh无法找到它.

Now since you are able to manually run the command npm, you just need to figure about the path from where npm is running and ensure that the path is explicitly added to the user's ~/.bashrc file and things should work fine. You need to do this because as per your observation, ssh is not able to find it.

export PATH=$PATH:/path/to/npm/binary

注意:为避免混淆,只需记住在将路径添加到二进制文件时,只需将路径添加到npm所在的目录即可.不要在末尾添加npm.例如,以下是不正确的方式:

Note: To avoid any confusion, just remember that while adding the path to your binary, you just have to add the path to the directory where npm resides. Don't add npm at the end. For example, following is incorrect way:

export PATH=$PATH:/home/handmast/bin/npm

正确的方法是这样:

export PATH=$PATH:/home/handmast/bin

这篇关于在共享主机上使用带位桶管道的ssh时找不到npm命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆