Amazon Beanstalk installs node and npm into really obscure places - and I'm not sure they won't change if EB decides to use a newer version of node, which would cause my application to break.
Amazon Beanstalk将节点和npm安装到非常模糊的地方——如果EB决定使用更新版本的节点,我不确定它们不会改变,这将导致我的应用程序中断。
These are the locations for node and npm:
这些是节点和npm的位置:
/opt/elasticbeanstalk/node-install/node-v0.8.24-linux-x64/bin/node
/opt/elasticbeanstalk/node-install/node-v0.8.24-linux-x64/bin/npm
I'm worried about the 0.8.24
part changing and I'd rather not grep for things in cron or monit scripts when trying to find something that is normally just /usr/bin/XXX
.
我担心0.8.24部分的改变,当我试图找到一些通常只是/usr/bin/ xxx的东西时,我宁愿不使用cron或monit脚本中的东西。
how do I get a consistent filepath for these executables? and why does EB do this?
如何为这些可执行文件获取一致的文件路径?为什么EB要这么做?
for reference, I tried setting the NodeVersion
option in an .ebextensions/app.config
, it had no effect on the install location.
作为参考,我尝试在. ebex/ app中设置NodeVersion选项。配置,它对安装位置没有影响。
5 个解决方案
#1
46
You can add the most recent node and npm binaries to $PATH with a command like this:
您可以使用如下命令将最近的节点和npm二进制文件添加到$PATH中:
PATH=$PATH:`ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin
I couldn't figure out how to prevent beanstalk commands from resetting the $PATH back again.
我不知道如何防止beanstalk命令重新设置$PATH。
If you are so inclined you can probably create a symlink with a command similar to the above and use that as your reference point in cron scripts etc.
如果您有这样的倾向,您可以创建一个符号链接与上面类似的命令,并将其用作cron脚本等中的引用点。
Agreed, it is very very annoying.
同意,这很烦人。
#2
24
Following Peter Johnson & Greg Tatum replies I created a symlink to the latest node executable:
在Peter Johnson & Greg Tatum回复之后,我创建了一个与最新的节点可执行文件的符号链接:
container_commands:
01_node_binary:
command: "ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/node /bin/node"
- I find the latest version of the node install binary
- 我找到最新版本的节点安装二进制文件
- Out of it I create a symlink in the /bin directory (which is part of the $PATH)
- 我在/bin目录中创建了一个symlink(这是$PATH的一部分)
#3
4
We had a similar issue with "node not found", trying to run node in container commands. After running ps aux
on the EC2 instance we saw that EB has access to the $NODE_HOME
env var:
我们在“未找到节点”中遇到了类似的问题,试图在容器命令中运行节点。在EC2实例上运行ps后,我们看到EB可以访问$NODE_HOME env var:
su -s /bin/sh -c PATH=$PATH:$NODE_HOME/bin $EB_NODE_COMMAND 2>&1 nodejs
This can be used in .ebextensions, e.g.:
这可以用在。ebextense,例如:
container_commands:
your_node_script:
command: 'env PATH="$PATH:$NODE_HOME/bin" ./bin/your_node_script'
(thanks to Alan Grow)
(感谢艾伦成长)
#4
2
I created the file /.ebextensions/node.config
in my project folder to declare my node version and add symlinks to the /bin folder. More information about the .ebextensions folder can be found here: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html
我创建了文件/. ebextense /node。在项目文件夹中配置,以声明节点版本并向/bin文件夹添加符号链接。有关. ebextense文件夹的更多信息可以在这里找到:http://docs.aws.amazon.com/elasticity beanstalk/latest/dg/customize containers-ec2.html
option_settings:
- option_name: NodeVersion
value: 0.12.2
files:
"/bin/node" :
mode: "755755"
content: "/opt/elasticbeanstalk/node-install/node-v0.12.2-linux-x64/bin/node"
"/bin/npm" :
mode: "755755"
content: "/opt/elasticbeanstalk/node-install/node-v0.12.2-linux-x64/bin/npm"
#5
1
Amazon Elastic Beanstalk
Grand the access to node command
- sudo su
- sudo苏
- vipw
- vipw
- nodejs:x:496:494::/tmp:/bin/bash (":wq" to save changes)
- nodejs:x: 496494:::/tmp:/bin/bash(“:wq”保存更改)
- sudo su nodejs
- sudo苏nodejs
- PATH=$PATH:
ls -td /opt/elasticbeanstalk/node-install/node-* | head -1
/bin - 路径=$PATH:ls -td /opt/ ticbeanstalk/ nodeinstall /节点-* | head -1/bin。
- node -v (enjoy :)
- 节点- v(享受:)
#1
46
You can add the most recent node and npm binaries to $PATH with a command like this:
您可以使用如下命令将最近的节点和npm二进制文件添加到$PATH中:
PATH=$PATH:`ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin
I couldn't figure out how to prevent beanstalk commands from resetting the $PATH back again.
我不知道如何防止beanstalk命令重新设置$PATH。
If you are so inclined you can probably create a symlink with a command similar to the above and use that as your reference point in cron scripts etc.
如果您有这样的倾向,您可以创建一个符号链接与上面类似的命令,并将其用作cron脚本等中的引用点。
Agreed, it is very very annoying.
同意,这很烦人。
#2
24
Following Peter Johnson & Greg Tatum replies I created a symlink to the latest node executable:
在Peter Johnson & Greg Tatum回复之后,我创建了一个与最新的节点可执行文件的符号链接:
container_commands:
01_node_binary:
command: "ln -sf `ls -td /opt/elasticbeanstalk/node-install/node-* | head -1`/bin/node /bin/node"
- I find the latest version of the node install binary
- 我找到最新版本的节点安装二进制文件
- Out of it I create a symlink in the /bin directory (which is part of the $PATH)
- 我在/bin目录中创建了一个symlink(这是$PATH的一部分)
#3
4
We had a similar issue with "node not found", trying to run node in container commands. After running ps aux
on the EC2 instance we saw that EB has access to the $NODE_HOME
env var:
我们在“未找到节点”中遇到了类似的问题,试图在容器命令中运行节点。在EC2实例上运行ps后,我们看到EB可以访问$NODE_HOME env var:
su -s /bin/sh -c PATH=$PATH:$NODE_HOME/bin $EB_NODE_COMMAND 2>&1 nodejs
This can be used in .ebextensions, e.g.:
这可以用在。ebextense,例如:
container_commands:
your_node_script:
command: 'env PATH="$PATH:$NODE_HOME/bin" ./bin/your_node_script'
(thanks to Alan Grow)
(感谢艾伦成长)
#4
2
I created the file /.ebextensions/node.config
in my project folder to declare my node version and add symlinks to the /bin folder. More information about the .ebextensions folder can be found here: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers-ec2.html
我创建了文件/. ebextense /node。在项目文件夹中配置,以声明节点版本并向/bin文件夹添加符号链接。有关. ebextense文件夹的更多信息可以在这里找到:http://docs.aws.amazon.com/elasticity beanstalk/latest/dg/customize containers-ec2.html
option_settings:
- option_name: NodeVersion
value: 0.12.2
files:
"/bin/node" :
mode: "755755"
content: "/opt/elasticbeanstalk/node-install/node-v0.12.2-linux-x64/bin/node"
"/bin/npm" :
mode: "755755"
content: "/opt/elasticbeanstalk/node-install/node-v0.12.2-linux-x64/bin/npm"
#5
1
Amazon Elastic Beanstalk
Grand the access to node command
- sudo su
- sudo苏
- vipw
- vipw
- nodejs:x:496:494::/tmp:/bin/bash (":wq" to save changes)
- nodejs:x: 496494:::/tmp:/bin/bash(“:wq”保存更改)
- sudo su nodejs
- sudo苏nodejs
- PATH=$PATH:
ls -td /opt/elasticbeanstalk/node-install/node-* | head -1
/bin - 路径=$PATH:ls -td /opt/ ticbeanstalk/ nodeinstall /节点-* | head -1/bin。
- node -v (enjoy :)
- 节点- v(享受:)