简体   繁体   English

无法从 Bash shell 脚本(松露)执行全局 Node.js 模块?

[英]Can't execute global Node.js module from Bash shell script (Truffle)?

I installed Truffle, the Ethereum development toolkit, on my Ubuntu 14.04 PC.我在 Ubuntu 14.04 PC 上安装了以太坊开发工具包 Truffle。 I can execute it easily from a terminal window by simply typing "truffle".我可以通过简单地输入“truffle”从终端 window 轻松执行它。 However, when I try to execute Truffle from a Bash shell script, I get the following error:但是,当我尝试从 Bash shell 脚本执行 Truffle 时,出现以下错误:

ide-do-truffle.sh: line 3: truffle: command not found

The line inside the shell script is just: shell 脚本内的行只是:

truffle compile --network local

How can I execute Truffle from within a shell script?如何从 shell 脚本中执行 Truffle?

If someone can also explain what goes on behind the scenes when you execute a globally installed Node.JS package like Truffle, that would be helpful too.如果有人还可以解释当您执行全局安装的 Node.JS package(如 Truffle)时幕后发生的事情,那也很有帮助。

Its possible the PATH in your terminal window is not the same as the PATH that your shell script sees.您的终端 window 中的PATH可能与您的 shell 脚本看到的PATH不同。

Try echo "$PATH" in both your terminal window and in your script just before your truffle line in your script, and compare the two.在您的终端 window 和脚本中的truffle行之前尝试echo "$PATH" ,然后比较两者。 If there is a difference, then the problem is with the PATH in your shell script.如果存在差异,则问题出在 shell 脚本中的PATH上。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM