同时尝试在具有以下结构的服务器上借助Fabric运行“ npm install” Ubuntu操作系统我收到错误“未找到npm命令”
I have installed node version v6.11.0 and npm version 3.10.10 on the server > user@ip-xx-xx-xx-xx:~$ npm -v > 3.10.10 > user@ip-xx-xx-xx-xx:~$ node -v > v6.11.0 system information cloud provider: aws OS: 16.04 LTS --------------------------------------------------------------------------- i have configured fabric on my local machine Fabric versoin > > user-system@xx-xxx-xxx-xx:fab --version > Fabric 1.14.0 > Paramiko 2.4.0 deploy(): require('stage', provided_by=(staging,)) if env.stage in ['staging']: with cd(env.app_dir): run(". ~/.nvm/nvm.sh") run("export PATH=/home/user/.nvm/versions/node/v6.11.0/bin/node:$PATH") run("export PATH=/home/user/.nvm/versions/node/v6.11.0/bin/npm:$PATH") run("/home/user/.nvm/versions/node/v6.11.0/bin/npm install")
python代码正在尝试在package.json文件中安装值为avialabe的npm
While executing the Fab script user@ip-XX_XX_XX_XX:# fab staging:'password' deploy [server@ip] Executing task 'deploy' [server@ip] run: . ~/.nvm/nvm.sh [server@ip] run: export PATH=/home/user/.nvm/versions/node/v6.11.0/bin/node:$PATH [server@ip] run: export PATH=/home/user/.nvm/versions/node/v6.11.0/bin/npm:$PATH [server@ip] run: /home/user/.nvm/versions/node/v6.11.0/bin/npm install [server@ip] out: /usr/bin/env: node: No such file or directory [server@ip] out: Fatal error: run() received nonzero return code 127 while executing! Requested: /home/user/.nvm/versions/node/v6.11.0/bin/npm install Aborting.
我的目标是运行命令 npm install 而不以root用户身份安装node或npm,而是借助nvm来为特定用户而非root配置节点。
答案 0 :(得分:0)
每个run
命令独立运行。如果您想做您想做的事情,请使用prefix
上下文管理器来更新PATH
。