python - 通过 Fabric 进行 npm 安装

标签 python node.js npm npm-install fabric

while trying to run "npm install" with help of fabric on a server with Ubuntu operating system i get an error "npm command not found"

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配置node。

<小时/>

最佳答案

每个run命令独立运行。如果您想做您想做的事情,请使用 prefix 上下文管理器来更新 PATH

关于python - 通过 Fabric 进行 npm 安装,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56974709/

相关文章:

python - 用python平滑线条路径

python - 如何将现有的矢量数据库加载到 Langchain 中?

python - BeautifulSoup lxml 解析器关闭不应出现的标签

node.js - 在 Dockerized Node.js 开发环境中处理 node_modules 的干净且实用的方法?

node.js - 捕获 npm 错误!从 shell 脚本运行 npm test 时

javascript - 有没有办法可以在后台从 cmd 行模拟 grunt 文件观察器?

python - Numpy 检查是否存在每行 < 0 的解决方案?

javascript - Mongoose :缓存虚拟

angularjs - Angular2 应用程序可以通过 package.json 安装和运行吗?

css - Angular UIKit npm 安装